// 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)((\s*\b([a-zA-Z_]*)\b)\s*((\s*=\s*(('[\w\-_#@,.!@#$%^&*()\s]*')))|((\s+\bLIKE\b\s+('[\w\-_#@,.!@#$%^&*()\s]*')))|(((\s+\bIN\b\s+\('[\w\-_#@,.!@#$%^&*()\s]+'(, '[\w\-_#@,.!@#$%^&*()\s]+')*\)))))((\s*\b(AND|OR)\b\s*)(\s*\b([a-zA-Z_]*)\b)\s*((\s*=\s*(('[\w\-_#@,.!@#$%^&*()\s]*')))|((\s+\bLIKE\b\s+('[\w\-_#@,.!@#$%^&*()\s]*')))|(((\s+\bIN\b\s+\('[\w\-_#@,.!@#$%^&*()\s]+'(, '[\w\-_#@,.!@#$%^&*()\s]+')*\))))))*)").unwrap();
let string = "sponsor_type_trial_company = 'Sponsor' AND
brief_title_trial LIKE '%heme%' AND brief_title_trial LIKE '%basket%'
outcome_trial_primary_outcome = 'Bladder Cancer'
AND sponsor_type_trial_company = 'Sponsor' AND
overall_status_trial IN ('Recruiting', 'Enrolling by invitation') AND trial_status_trial = 'Open' AND official_title_trial LIKE '%Japan%'
overall_status_trial IN ('Recruiting', 'Not yet recruiting', 'Active, not recruiting') AND biomarker_strategy_trial_biomarker = 'HER2 low' AND indication_trial_indication = 'Breast Cancer'
trial_phase_trial='Phase 3' AND stage_trial_indication_stage='Stage IV' AND outcome_acronym_trial_primary_outcome='PFS'";
// 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/