// 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)Client=(\w+[ \w+]*);?").unwrap();
let string = "Client=EBA;Action=OneNotePagePreviewsRealtimeProcessor
Client=EBssssA;Action=OneNotePagePreviewsRealtimeProcessor
Client=some other;Action=OneNotePagePreviewsRealtimeProcessor
Client=some other word long;Action=OneNotePagePreviewsRealtimeProcessor
Client=OWA;Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; InfoPath.2; SLCC2; Media Center PC 6.0);
Client=Hub Transport
Client=OWA;Mozilla/5.0 (Linux; Android 10; Redmi Note 8T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.91 Mobile Safari/537.36;
Client=WebServices;macOS/11.2.2 (20D80) CalendarAgent/954;
Client=OutlookService;microsoft.windowscommunicationsapps;";
// 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/