// 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"\[(?P<timestamp>[\w-]+\s[\w:]+[+\.]\d+)\] \[(?P<level>\S+)\]\:(?P<bho>\s+)\t\{(?P<id>\d+)\} \[(?P<telefono>\S+)\] \[(?P<ip>\S+)\] (?P<node>\w*)\s*\[(?P<path>\S+)?\s\]\[(?P<bho2>\s\d+\s)\]\[\s(?P<id2>\d+\s)\]").unwrap();
let string = "[2020-05-22 12:49:09.1640] [info]: {2012} [393471039213] [10.8.19.191] MASTER [netmon.condiviso_368-pwc ][ 160239552803493 ][ 1292 ]
[2020-02-13 01:01:03.9170] [info]: {2} [393454639076] [10.8.4.218] MASTER [netmon.condiviso_368-pwc ][ 160130554375066 ][ 1855 ]
[2020-02-13 02:10:05.5750] [info]: {499} [393481505158] [10.8.17.5] [netmon.traffico.393481505158.10.8.17.5_371-pwc ][ 4880942571 ][ 16274 ]";
// 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/