// 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).*?{"EVENT_NAME":"(?<tag6>[^"]*)","EVENT_ID":"(?<action>[^"]*)","User_Id":"(?<login>[^"]*)","X_Corelation_ID":"(?<policy>[^"]*)","Client_IPAddress":"(?<sip>[^"]*)","Acting_As_ID":"(?<account>[^"]*)","Message":"(?<tag2>[^"]*)"}"#).unwrap();
let string = "[2019-01-15 13:44:43,432] [[ACTIVE] ExecuteThread: '45' for queue: 'weblogic.kernel.Default (self-tuning)'] WARN SiemLogger - {\"EVENT_NAME\":\"SIEM\",\"EVENT_ID\":\"LOGOUT\",\"User_Id\":\"ROBKNT1810\",\"X_Corelation_ID\":\"null\",\"Client_IPAddress\":\"null\",\"Acting_As_ID\":\"null\",\"Message\":\"MobileSignOutPage - User successfully logged out.\"}
";
// 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/