// 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)(-x ("|'))(\w+)\2(?!.*(?1)\3["|'])"#).unwrap();
let string = "testuser /get_results.sh -q -x 'igp_srm_m' -s 'yesterday' -e 'yesterday' -m '2048' -b >>'/var/log/process/srm-console.log' 2>&1
00 10 * * 2-6 testuser /get_results.sh -q -x 'igp_srm_m' -s 'yesterday' -e 'yesterday' -m '2048' -w '720' >>'/var/log/process/srm-console.log' 2>&1
00 08 * * 1-5 testuser /get_results.sh -q -x \"igp_srm_m\" -s \"today\" -e \"today\" -m \"90000\" -b -z partA >>\"/var/log/process/france-partA-console.log\" 2>&1
00 12 * * 2-6 testuser /get_results.sh -q -x \"igp_france\" -s \"yesterday\" -e \"yesterday\" -m \"90000\" -w \"900\" -z partA >>\"/var/log/process/france-partA-console.log\" 2>&1
00 08 * * 1-5 testuser /get_results.sh -q -x \"igp_france\" -s \"today\" -e \"today\" -m \"90000\" -b -z partB >>\"/var/log/process/france-partB-console.log\" 2>&1
00 12 * * 2-6 testuser /get_results.sh -q -x \"igp_france\" -s \"yesterday\" -e \"yesterday\" -m \"90000\" -w \"900\" -z partB >>\"/var/log/process/france-partB-console.log\" 2>&1
00 12 * * 2-6 testuser JAVA_OPTS='-server -Xmx512m' /merge.sh \"yesterday\" \"igp_france\" \"partA,partB\" >>\"/var/log/process/france-console.log\" 2>&1
00 08 * * 1-5 testuser /get_results.sh -q -x \"igpswitz_france\" -s \"today\" -e \"today\" -m \"15000\" -b >>'/var/log/process/igpswitz_france-console.log' 2>&1
00 12 * * 2-6 testuser /get_results.sh -q -x \"igpswitz_france\" -s \"yesterday\" -e \"yesterday\" -m \"15000\" -Dapc.maxalerts=8000 -w \"900\" >>'/var/log/process/igpswitz_france-console.log' 2>&1
30 07 * * 2-6 testuser /get_results.sh -q -x \"igp_franced\" -s 'yesterday' -e 'yesterday' -m \"105000\" -b >>\"/var/log/process/franced-console.log\" 2>&1
15 12 * * 2-6 testuser /get_results.sh -q -x \"igp_franced\" -s 'yesterday' -e 'yesterday' -m \"105000\" -w \"960\" >>\"/var/log/process/franced-console.log\" 2>&1
";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
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/