// 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)(?ms)EventCode\=5145.*Message\=A network share object was checked to see whether client can be granted desired access.").unwrap();
let string = "LogName=Security
SourceName=Microsoft-Windows-Security-Auditing
EventCode=5145
EventType=4
Type=Success Audit
ComputerName=xxxx
Category=11111
CategoryString=none
RecordNumber=xxxx
Message=A network share object was checked to see whether client can be granted desired access.
Subject:
Security ID:
Account Name:
Account Domain:
Logon ID:
Network Information:
Object Type: File
Source Address:
Source Port:
Share Information:
Share Name:
Share Path: \\
Relative Target Name: x.dxmdg.com\\Policies\\{123456789456456456454654464546464558655}\\Machine\\Preferences\\Registry\\Registry.xml
Access Request Information:
Access Mask:
Accesses:
Access Check Results:";
// 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/