// 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"(?<=Code:).*Distribution\s([\d.,]+)(?=\n)").unwrap();
let string = "Code: 210 - Test 1 - Distribution
267745 Vis - Branch Deposit 3/10/2021 2,000.00
468040 v- Branch Deposit 2/10/2021 1,700.00
586075 Visa 3/3/2021 555.48
502490 Vis 3/4/2021 1,835.51
403195 Vis 3/4/2021 2,033.56
500230 Vis 3/4/2021 651.29
Code: 210 - Test - Distribution 8,775.84
Code: 230 - Greenville - Distribution
853955 Clearing 2/1/2021 77.50";
// 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/