// 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)^((0?\d)|([12]\d)|(3[01]))?\.?((0?\d)|(1[012]))?\.?((\d)|(\d\d)|(\d{3})|(19\d\d)|(20[0-3]\d))?$").unwrap();
let string = "23.04.1988
5.9.11
12.12.20
02.02.02
02.02.0
02.02.
02.02
02
9
32.02.1999
12.13.2017
a2.03.2017
5.13.
12.12.1880
12.12.2100
";
// 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/