// 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)sm-mta\[.*\]:\s(?<qid>.*?):").unwrap();
let string = "Feb 19 00:05:04 smtp2 sm-mta[28608]: l1J652ZW028608: from=<dsbugeyed@example.org>, size=15433, class=0, nrcpts=1, msgid=<001001c75437$5633fa90$06aeb57c@samsungtkb30u2>, proto=SMTP, daemon=MTA, relay=[58.78.156.175]";
// 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/