// 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)^(?=.{8}$)(?:(?:[a-z]+|[0-9]+)(?:-|$)){3}").unwrap();
let string = "aa-99-99
99-23-bd
02-xx-04
ab-99-cz
sc-xd-49
99-xav-4
48-xyz-09
9-abc-01
xs-899-x
sss-99-x
10-b1-c2
aa-bb-01
10-11-ac";
// 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/