// 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#"\"app\":\s\{((.|\n)*)\"local\""#).unwrap();
let string = "{
\"app\": {
\"local\": \"True\",
\"dependency_env\": \"dev\"
},
\"engine\": {
\"disable_jwt_check\": \"true\",
\"jwt_private_key\": \"sph59tZqVrjqz3BiVUnXvKRgd6BxDkN2E+TAjy96wfASO4/5DGJIQlZvnNSt4H7wKLQ0b1J5AdNJ7315B9My6w==\",
\"jwt_issuer\": \"https://hbgpmwapi-dev.kantar.com\"
},
\"azure\": {
\"app_id\": \"efe4d19e-880e-480e-8e0c-f86c9fd5872c\",
\"app_key\": \"b1e5em8uILeqAI.0jt=zg[mJHSaaHKz:\",
\"env\": \"dev\",
\"storage_key\": \"pKhqboH2XDRpYNLco4vyPapHNd7Ao/BO28yFBD0ooSSn/828NLMfKkkzdrqUyeeA2312Y9xAix1T/YdAHkbZCw==\",
\"storage_container\": \"marketingpressure\",
\"storage_endpoint\": \"https://hbgenginestorage.blob.core.windows.net\"
},
\"URL\": {
\"main\": \"http://localhost:3838\"
}
}";
// result will be a tuple containing the start and end indices for the first match in the string
let result = regex.captures(string);
let (start, end) = match result {
Some((s, e)) => (s, e),
None => {
// ...
}
};
println!("{}", &string[start, end]);
}
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/