// 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"(From:[^<\n\r]*<[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-.]+>)\n(Sent:[\r\s](Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday),[\r\s\S]*(AM|PM))\n(To:[\s]*[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-.]+)\n(Cc:[^\r\n]*[\r\n])?(Subject:[\s]*[^\n\r]*[\n\r])").unwrap();
let string = "asdasd
From: kunal with love <kunal.singh@sprinklr.com>
From: Kunal Singh <kunal.singh@sprinklr.com>
Sent: Wednesday, February 28, 2018 4:38 PM
To: kevinroberts192@outlook.com
Cc: Arjit Srivastava
Subject: fwd with cc and bcc
cc and bcc";
// 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/