// 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)\s*(?:"([^"]*)"|([^,""<>]*))?\s*(?:(?:,|<|\s+|^)([^<@\s,]+@[^>@\s,]+)>?)\s*"#).unwrap();
let string = "Test1 <test1@x.com>, Test Two test2@x.y.com,T e s t 3 <test3@z.com>, Test@4 <test4@abc.com>, test5@cde.com,
\"Bob Smith\" <bob@company.com>, joe@company.com, \"John Doe\"<john@company.com>, Billy Doe<billy@company.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/