// 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).(.*)(]\s)(.[a-zA-Z]*)(..)(.*)").unwrap();
let string = "[1518-08-11 00:47] falls asleep
[1518-03-09 00:07] falls asleep
[1518-06-29 00:41] wakes up
[1518-05-27 23:58] Guard #743 begins shift
[1518-05-19 00:43] falls asleep
[1518-03-17 00:33] falls asleep
[1518-07-12 00:49] falls asleep
[1518-11-03 00:15] wakes up
[1518-06-05 00:57] wakes up
[1518-11-07 00:24] falls asleep
[1518-07-06 00:12] falls asleep
[1518-05-26 23:59] Guard #907 begins shift
[1518-06-01 00:28] wakes up
[1518-11-09 00:04] falls asleep
";
// 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/