// 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)((?:\d{2}:)?\d{2}:\d{2}\.\d{3})[^\n]+level[^\d]+(\d{3})").unwrap();
let string = "00:00.300 ID:4 zzzzzzzzzzz
00:02.155 ID:4 aaaaaaaaaaaaa
00:04.662 ID:4 dsadasd
**00:32.283** ID:4 level **790**
00:32.155 ID:4 Sfghgfs
00:32.200 ID:4 Tsdfsdfdfsff
**00:32.205** ID:4 level **640**
00:32.206 ID:4 Sadssd
00:32.208 ID:4 asdasgsfgsgsagsa
00:32.210 ID:4 adasgx
00:32.212 ID:4 Masddasdas.
**01:40:40.698** ID:4 level **500**";
// 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/