// 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"(?ms)model: ([^\n]+)(.*)bitmap [^\n]+").unwrap();
let string = "# model: pmy0_footr015
filedependancy Unknown
newmodel pmy0_footr015
setsupermodel pmy0_footr015 NULL
classification Character
setanimationscale 1.0
beginmodelgeom pmy0_footr015
node dummy pmy0_footr015
parent NULL
endnode
node trimesh pmy0_footr015g
parent pmy0_footr015
position 0.0 0.0 0.0
orientation 1.0 0.0 0.0 0.0
bitmap pmh0_footr050
verts 15
-0.0378169 -0.00381612 0.00857995";
let substitution = "model: $1$2bitmap $1";
// 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/