// 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)SSR.(....)(.BE.)(\w+)(-1)(\w+)(\/)(\w+).*").unwrap();
let string = "SSR BAGW BE HK1DUBEXT0304H13OCT-1TIMBRELL/TEGAELAMISS.1P/AUTH 23KG
SSR BAGA BE HK1DUBLON0301H13NOV-1TIMBRELL/TEGAELAMISS.1P/AUTH 23KG
SSR DOCS BE HK1DUBEXT0204H13DEC-1TIMBRELL/TEGAELAMISS
SSR PETC BE HK1LONEXT0334H13JAN-1TIMBRELL/TEGAELAMISS
SSR WCHR BE HK1DUBEXT0204H13DEC-1TIMBRELL/TEGAELAMISS
SSR BAGW BE HK1DUBLON0301H13NOV-1TIMBRELL/TEGAELAMISS.1P/AUTH 23KG
BE7351 H 08NOV18MANMXP HK4/11251440
BE2108R/VS8508Y 11NOV18LHREDI HK10/18202000
A97351 H 08NOV18MANMXP HK4/11251440";
let substitution = "\\1-\\5-\\7";
// 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/