// 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#"(?i)([^\s=]+)=(?|"([^"]*)"|(\S+))"#).unwrap();
let string = "date=2019-05-10 time=11:50:48 logid=\"0001000014\" type=\"traffic\" subtype=\"local\" level=\"notice\" vd=\"vdom1\" eventtime=1557514248379911176 srcip=172.16.200.254 srcport=62024 srcintf=\"port11\" srcintfrole=\"undefined\" dstip=172.16.200.2 dstport=443 dstintf=\"vdom1\" dstintfrole=\"undefined\" sessionid=107478 proto=6 action=\"server-rst\" policyid=0 policytype=\"local-in-policy\" service=\"HTTPS\" dstcountry=\"Reserved\" srccountry=\"Reserved\" trandisp=\"noop\" app=\"Web Management(HTTPS)\" duration=5 sentbyte=1247 rcvdbyte=1719 sentpkt=5 rcvdpkt=6 appcat=\"unscanned\"
";
// 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/