// 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)199\d{1}|20\d{2}|\d{2}(?![/,\-\w ])").unwrap();
let string = "04/20/2001; 04/20/11; 4/20/09; 4/3/01
Mar-20-2001; Dec 20, 2009; April 20, 2009; Mar. 20, 2009; Mar 20 2009;
20 Mar 2001; 20 April 2001; 20 Mar. 2007; 20 March, 2009
Mar 21th, 2009; Mar 21st, 2009; Feb 22nd, 2002
Feb 2009; Sep 2009; Nov 2016
6/2008; 12/2009
2003; 2012";
// 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/