// 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)("UID\s*([^\n\r]*))"#).unwrap();
let string = "{
\"Tabelle1\": [
{
\"Nr.\": \"1\",
\"Firma\": \"Alba Reisen/Versicherungen/Darlehen H. Kajtazi\",
\"Rechtsform\": \"EIU\",
\"Sitz\": \"Rapperswil-Jona\",
\"Kanton\": \"SG\",
\"UID\": \"CHE‑101.868.757\"
},
{
\"Nr.\": \"2\",
\"Firma\": \"Alybaba - Schischa Laden, Aly\",
\"Rechtsform\": \"EIU\",
\"Sitz\": \"Wil (SG)\",
\"Kanton\": \"SG\",
\"UID\": \"CHE‑102.012.121\"
},
{
\"Nr.\": \"3\",
\"Firma\": \"Bluamawerkstatt zur Linde Marianne Bislin-Lieberherr\",
\"Rechtsform\": \"EIU\",
\"Sitz\": \"Pfäfers\",
\"Kanton\": \"SG\",
\"UID\": \"CHE‑217.602.289\"
},
]
}
";
let substitution = "$1,\"X\":\"\"";
// 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/