// 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#"((?<=<|<\/)|(?<= ))[A-Za-z0-9]+:| xmlns(:[A-Za-z0-9]+)?=".*?""#).unwrap();
let string = "<?xml version=\"1.0\" encoding=\"utf-16\"?>
<ArrayOfInserts xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">
<insert>
<offer xmlns=\"http://schema.peters.com/doc_353/1/Types\">0174587</offer>
<type2 xmlns=\"http://schema.peters.com/doc_353/1/Types\">014717</type2>
<supplier xmlns=\"http://schema.peters.com/doc_353/1/Types\">019172</supplier>
<id_frame xmlns=\"http://schema.peters.com/doc_353/1/Types\" />
<type3 xmlns=\"http://schema.peters.com/doc_353/1/Types\">
<type2 />
<main>false</main>
</type3>
<status xmlns=\"http://schema.peters.com/doc_353/1/Types\">Some state</status>
</insert>
</ArrayOfInserts>";
let substitution = "";
// 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/