// 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"(?ms)^(?=.*?# end of message)(?!.*?start of message)[^\s#].+?$").unwrap();
let string = "
================REPORT================
Run Details
==============================================
This belongs to xyz run: start of message
#comments about the message
Error details 1
Error details 2
Error details 3
# end of message
==============================================
Run Time Information
==============================================
";
// 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/