// 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}).(20\d{2})").unwrap();
let string = "Example 1 (Colon)
Payee: John Smith
Account No: 145-567-981
Date: 19.01.2020
Time: 08:01
Email: JohnSmith@gmail.com
Example 2 (the dash)
John Smith - Payee
145 567 981 - Account No
19-01-2020 - Date
08:01 - Time
John.Smith@hotmail.com - Email
Example 3 (the dashes AND all one line of text)
Payee - John Smith - Account No - 145.567.9815 - Date - 19,1,2020 - Time - 08:01 - Email - John.Z.Smith@yahoo.com";
// 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/