// 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)"Status":("?)(?<cstatus>.*?)("?),.*?"ProblemFlag":("?)(?<probflag>.*?)("?),.*?"IncreasePending":("?)(?<increasePend>.*?)("?),.*?"SafePay":("?)(?<safepay>.*?)("?),"PastDue":("?)(?<pastdue>.*?)("?),"LastPmtAmt":("?)(?<lastpayamt>.*?)("?),"NextPmtAmt":("?)(?<nextpayamt>.*?)("?),"LastPayDate":("?)(?<lastpaydate>.*?)("?),"NextDebitDate":("?)(?<nextdbtdate>.*?)("?),"AddendumDate":("?)(?<addendmdate>.*?)("?)}"#).unwrap();
let string = "{\"Status\":\"AP\",\"ProblemFlag\":\"0\",\"IncreasePending\":\"1\",\"SafePay\":\"1\",\"PastDue\":\"0\",\"LastPmtAmt\":\"0.00\",\"NextPmtAmt\":\"453.00\",\"LastPayDate\":\"\",\"NextDebitDate\":\"2021-02-28 00:00:00\",\"AddendumDate\":\"2021-02-15 00:00:00\"}";
// 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/