// 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)(\"\$basetexture\".*)"#).unwrap();
let string = "\"LightmappedGeneric\"
{
\"$basetexture\" \"Concrete/concrete_modular_floor001a\"
\"$surfaceprop\" \"concrete\"
\"%keywords\" \"portal\"
}
\"LightmappedGeneric\"
{
\"$nobasetexture\" \"Concrete/concrete_modular_floor001a\"
\"$surfaceprop\" \"concrete\"
\"%keywords\" \"portal\"
}";
let substitution = "\\1\\n\\t\"$basetexturetransform\" \"center .5 .5 scale 4 4 rotate 0 translate 0 0\"";
// 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/