// 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)\"orderId\":\"(?<orderId>[^\"]+)\"},\"error\":\{\"errorCode\":\"(?<errorCode>[^\"]+)\""#).unwrap();
let string = "message: Send jms message [queue=SEP.TO.PEIN, statusCode=200, idempotencyId=b95d0d10-9709-4299-9d3e-8c65dd5a539d, processId=PE2400000582026, delivApp=null, message={\"transactionItems\":[{\"itemId\":\"4f2170cd-35f6-4d03-b0fe-6ebbca6e00cb\",\"status\":\"FAILED\",\"accountIdentification\":{\"contractAccountNumber\":{\"branchCode\":\"0784\",\"accountNumber\":\"0190595009\",\"currencyCode\":\"INR\"}}},{\"itemId\":\"adea3dff-8e02-433e-a2ad-94bac828989b\",\"status\":\"FAILED\",\"accountIdentification\":{\"contractAccountNumber\":{\"branchCode\":\"0784\",\"accountNumber\":\"0190595009\",\"currencyCode\":\"INR\"}}},{\"itemId\":\"bf96b534-2150-4228-843f-9fb920a1f44f\",\"status\":\"FAILED\",\"accountIdentification\":{\"contractAccountNumber\":{\"branchCode\":\"0784\",\"accountNumber\":\"0190595009\",\"currencyCode\":\"INR\"}}},{\"itemId\":\"cb6e42ac-ee83-48b6-8213-7faf0311c6d0\",\"status\":\"FAILED\",\"accountIdentification\":{\"contractAccountNumber\":{\"branchCode\":\"0784\",\"accountNumber\":\"0190595009\",\"currencyCode\":\"INR\"}}},{\"itemId\":\"bdd8a76f-ddb4-4616-a793-68ddd72aad0e\",\"status\":\"FAILED\",\"accountIdentification\":{\"contractAccountNumber\":{\"branchCode\":\"0784\",\"accountNumber\":\"0190595009\",\"currencyCode\":\"INR\"}}},{\"itemId\":\"cb339f2a-ad85-410c-9043-275aa1e4fe17\",\"status\":\"FAILED\",\"accountIdentification\":{\"contractAccountNumber\":{\"branchCode\":\"0784\",\"accountNumber\":\"0190595011\",\"currencyCode\":\"INR\"}}}],\"orderStatusResponse\":{\"orderStatus\":\"ORDER_FAILURE\",\"orderId\":\"b95d0d10-9709-4299-9d3e-8c65dd5a539d\"},\"error\":{\"errorCode\":\"SEP013\",\"errorDescription\":\"Cannot find IDMS-0784 account by accNumber: 0190595009\"}}]";
// 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/