// 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|1)[0-9])\/([0-3][0-9])\/([0-9][0-9])").unwrap();
let string = "01/01/20
02/01/20
03/01/20
04/01/20
05/01/20
06/01/20
07/01/20
08/01/20
09/01/20
10/01/20
11/01/20
12/01/20
01/32/20
01/03/20
01/04/20
01/05/20
01/06/20
01/07/20
01/08/20
01/09/20
01/10/20
01/11/20
01/12/20
01/13/20
01/14/20
01/15/20
01/16/20
01/17/20
01/18/20
01/19/20
01/20/20
01/21/20
01/22/20
01/23/20
01/24/20
01/25/20
01/26/20
01/27/20
01/28/20
01/29/20
01/30/20
01/31/20
";
// 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/