// 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"(?mi)failed:.*\,").unwrap();
let string = "{Client:100.96.43.15,ElapsedMilliseconds:214,EndTime:2019-10-02T20:18:56.027320,Failed:0,Name:MasterAddress,Results:[{ElapsedMilliseconds:213,EndTime:2019-10-02T20:18:56.027291,Result:{AddressTypeCode:STANDARD,ID:00A-27P-15Q,Municipality:{Name:Windsor,StateProvince:{Code:ON,Country:{Code:CA}}},PostalCode:{Value:N8S0A1},Street:{Name:McHugh,StreetType:{Abbreviation:{en:St,fr:St},Value:{en:Street,fr:Street}}},StreetNumber:8787},StartTime:2019-10-02T20:18:55.813313,Success:true}],Server:master-address-68bf54d578-vczph,StartTime:2019-10-02T20:18:55.813162,StatusCode:200,Succeeded:1,TimedOut:0,Version:1.0}
";
// 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/