// 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{4}-\d{2}-\d{2}T\d\d:\d\d:\d\d+\+\d\d:\d\d\s+(?<device>[^ ]+)\s+\<\d+\>\s+\%(?<alarm>\w+-\w+)[^ ]*\s+\(\d+\)\s+(?<message>[^\(]+)((\s+\(\d+\s+)|$)").unwrap();
let string = "2020-04-04T15:08:01+00:00 usdaldc <44> %WAAS-HTTPAO-4-131001: (843570) worker pool isn't healthy
2020-04-04T15:08:01+00:00 usdaldc <43> %WAAS-HTTPAO-3-131003: (843509) AOSHELL worker thread (28814 0.0) stuck for 650000 msec: start 0x7feedd6aa880(/cisco/lib64/libaoshell.so+0x50880), callback 0x4a6140(/sw/unicorn/bin/http_ao64+0xa6140)";
// 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/