// 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)(?<=SUBH2002078568)[\s\S]+?(?=SUBF2002078568)").unwrap();
let string = "HMT940040324
SUBH2002078568
2002078568{1:F01BANK MBI}{2:I940MAP}{4:
2002078568:20:20210420182417
2002078568:25:2002078568
2002078568:28C:00075
2002078568:60F:D210420IDR0,
2002078568:62F:D210420IDR0,
2002078568-}
SUBF2002078568
SUBH2003001298
2003001298{1:F01BANK MBI}{2:I940MAP}{4:
2003001298:20:20210420182417
2003001298:25:2003001298
2003001298:28C:00075
2003001298:60F:C210420IDR111520964,38
2003001298:62F:C210420IDR111520964,38
2003001298-}
SUBF2003001298
SUBH2002078568 // *Added this account from the top*
2002078568{1:F01BANK MBI}{2:I940MAP}{4:
2002078568:20:20210420182417
2002078568:25:2002078568
2002078568:28C:00075
2002078568:60F:D210420IDR0,
2002078568:62F:D210420IDR0,
2002078568-}
SUBF2002078568- // End
FMT9400000004";
// 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/