// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r"(?m)^z[0-3|6-8]{1}$|^z5(ab|c)$|^z12c$|^z1[5-7]$|^z20$").unwrap();
let string = "z0
z1
z2
z3
z4
z5
z5a
z5b
z5ab
z5c
z6
z7
z8
z9
z10
z11
z12
z12c
z13
z14
z15
z16
z17
z18
z19
z20";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Rust, please visit: https://docs.rs/regex/latest/regex/