// 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"(?ism)Date:\n(.*)\n\nNumber").unwrap();
let string = "Voice Mail Message: Double click on the attachment to play the voice mail file.
Date:
12/01/2014 01:28:36 PM
Number:
800-123-4567, JOHN SMITH
CallerID:
123-456-7890, JANE DOE
Destination:
Voice Mail
File Duration:
00:00:37
======================
Name : Jane Doe
Address : 123 Fake Street , Miami , Florida
Phone : 123-456-7890
Ye, my name is Jane Doe. I own the property at 123 Fake Street , Miami , Florida. You sent me a couple of postcards. Let me know if you're interested in making an offer. it's a single family home.3 bedrooms, 2 baths. Has a single efficiency in the back, that's an additional rental income.
Again, Jane Doe and that's 123 Fake Street and my phone number is 123-456-7890. Thanks !
";
// result will be a tuple containing the start and end indices for the first match in the string
let result = regex.captures(string);
let (start, end) = match result {
Some((s, e)) => (s, e),
None => {
// ...
}
};
println!("{}", &string[start, end]);
}
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/