// 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)^\d{1,2}([ -.\/])(\d{1,2}|[a-zA-z]{3,15})(?1)\d{2,4}( \d{2}:\d{2}(:\d{2}([.:]\d)?)?)?$|^(\d{1,2}|[a-zA-z]{3,15})([ -.\/])\d{1,2}(?7)\d{2,4}( \d{2}:\d{2}(:\d{2}([.:]\d)?)?)?$|^\d{2,4}([ -.\/])(\d{1,2}|[a-zA-z]{3,15})\d{1,2}(?11)( \d{2}:\d{2}(:\d{2}([.:]\d)?)?)?$").unwrap();
let string = "23/02/1993
23-02/1993
23-fev-1993
fev-23-1993
fev.02.93
28-OCT-90
28-OCT-1990
10/28/90
10/28/1990
28.10.90
dd.mm.yyyy
28.10.1990
90/10/28
yyyy/mm/dd
1990/10/28
4 Q 1990
OCT 90
OCT 1990
01:02
01:02:34.75
02:34
02:34.75
20 08:03
20 08:03:00
20-JUN-1990 08:03
20-JUN-1990 08:03:00
1990-06-20 08:03
1990-06-20 08:03:00.0";
// 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/