// 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)^var (.*?Infos) = .*?data: (.*?),$").unwrap();
let string = "var syntheticResponseTimeDistributionInfos = {
data: {\"result\": {\"minY\": 1.0, \"minX\": 0.0, \"ticks\": [[0, \"Requests having \\nresponse time <= 500ms\"], [1, \"Requests having \\nresponse time > 500ms and <= 1,500ms\"], [2, \"Requests having \\nresponse time > 1,500ms\"], [3, \"Requests in error\"]], \"maxY\": 37.0, \"series\": [{\"data\": [[0.0, 37.0]], \"color\": \"#9ACD32\", \"isOverall\": false, \"label\": \"Requests having \\nresponse time <= 500ms\", \"isController\": false}, {\"data\": [], \"color\": \"yellow\", \"isOverall\": false, \"label\": \"Requests having \\nresponse time > 500ms and <= 1,500ms\", \"isController\": false}, {\"data\": [], \"color\": \"orange\", \"isOverall\": false, \"label\": \"Requests having \\nresponse time > 1,500ms\", \"isController\": false}, {\"data\": [[3.0, 1.0]], \"color\": \"#FF6347\", \"isOverall\": false, \"label\": \"Requests in error\", \"isController\": false}], \"supportsControllersDiscrimination\": false, \"maxX\": 3.0, \"title\": \"Synthetic Response Times Distribution\"}},
getOptions: function() {
return {
var activeThreadsOverTimeInfos = {
data: {\"result\": {\"minY\": 1.0, \"minX\": 1.5931058172E12, \"maxY\": 1.0, \"series\": [{\"data\": [[1.5931058186E12, 1.0], [1.5931058196E12, 1.0], [1.5931058175E12, 1.0], [1.5931058185E12, 1.0], [1.5931058195E12, 1.0], [1.5931058205E12, 1.0], [1.5931058184E12, 1.0], [1.5931058194E12, 1.0], [1.5931058204E12, 1.0], [1.5931058173E12, 1.0], [1.5931058183E12, 1.0], [1.5931058193E12, 1.0], [1.5931058203E12, 1.0], [1.5931058172E12, 1.0], [1.5931058213E12, 1.0], [1.5931058192E12, 1.0], [1.5931058202E12, 1.0], [1.5931058212E12, 1.0], [1.5931058181E12, 1.0], [1.5931058191E12, 1.0], [1.5931058201E12, 1.0], [1.5931058211E12, 1.0], [1.593105818E12, 1.0], [1.593105819E12, 1.0], [1.59310582E12, 1.0], [1.593105821E12, 1.0], [1.5931058179E12, 1.0], [1.5931058189E12, 1.0], [1.5931058209E12, 1.0], [1.5931058178E12, 1.0], [1.5931058198E12, 1.0], [1.5931058208E12, 1.0], [1.5931058177E12, 1.0], [1.5931058187E12, 1.0], [1.5931058197E12, 1.0], [1.5931058207E12, 1.0], [1.5931058176E12, 1.0]], \"isOverall\": false, \"label\": \"ThreadGroup\", \"isController\": false}, {\"data\": [[1.5931058224E12, 1.0], [1.5931058217E12, 1.0]], \"isOverall\": false, \"label\": \"tearDown Thread Group\", \"isController\": false}], \"supportsControllersDiscrimination\": false, \"granularity\": 100, \"maxX\": 1.5931058224E12, \"title\": \"Active Threads Over Time\"}},
getOptions: function() {
";
let substitution = "var $1 = {\\n data: $1_data,";
// 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/