// 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)(?=:90C:|:90D:)(.*?)ABC(\S+)").unwrap();
let string = " :20: LAIDKZPABCL90165LZJABC
:90: LZ,90509LAOABCXL,XKPA;AOLZ
:90C: KDOLASABC9080690ABD
:90D: ABDBABC906AODIPALKD
:90L: AND9011112XXXADABC
:90: AKLZPDOAMXNA,;POAS";
let substitution = "$1XYZ$2";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", result);
}
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/