// 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"seqno: (\d+).+?src: (\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}).+?dst: (\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}).+?srcuser: (.+)?<br\/>").unwrap();
let string = "domain: 1<br/>receive_time: 2017/10/25 13:47:19<br/>serial: 00790100000<br/>seqno: 7198725<br/>actionflags: 0x0<br/>type: THREAT<br/>subtype: spyware<br/>config_ver: 1<br/>time_generated: 2017/10/25 13:47:19<br/>src: 1.1.1.1<br/>dst: 2.2.2.2<br/>natsrc: 1.1.1.1<br/>natdst: 2.2.2.2<br/>rule: to INTERNET<br/>srcuser: me<br/>blabla";
// 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/