// 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-Z]+)(\s)*(:))){1}(\s)*(((?:[\[])?(?:["])?((.)*)(?:["])?(?:[\]]?))?)?([,]?)"#).unwrap();
let string = "{
id: \"00000000-0000-0000-0000-000000000000\",
numericId: 0,
accountId: \"00000000-0000-0000-0000-000000000000\",
accountCode: \"\",
groups: [\"group1\"],
isTest: true,
ftpInfo: {
host: \"127.0.0.1\",
port: 21,
homeDirectory: \"/\",
fileMask: \"*.txt\",
username: \"\",
password: \"\",
isPassive: true,
isBinary: true
},
contactName: \"\",
contactEmailAddress: \"\",
createdOn: \"1900-01-01T00:00:00\",
modifiedOn: \"1900-01-01T00:00:00\"
}";
let substitution = "\"$3\": $7$11";
// 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/