// 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"(?i).*cc.*(cor.*ang.*|heart.*|icd.*|pace.*|coronary.*|cardi.*|aortic.*|lhc.*|.rhc.*|dual.*lead.*|cabg.*|trans.*echo.*)
").unwrap();
let string = "CC AORTIC ROOT INJECTION
CC CARDIOVERSION
CC COR ANG BYPASS W/LHC
CC COR ANG BYPASS W/R-LHC
CC COR ANGIO BYPASS
CC COR ANGIO W/LHC
CC COR ANGIO W/R-LHC
CC COR ANGIO W/RHC
CC CORONARY ANGIO
CC CORONARY ANGIO, CC COR ANGIO W/LHC
CC DUAL LEAD ONLY, INSERT
CC HEART CATH LEFT HEART
CC HEART CATH LEFT HEART, CC HEART CATH R+L ADULT
CC HEART CATH R+L ADULT
CC ICD DUAL CHAMBER
CC ICD GEN REMOVE
CC ICD GEN REP MULT LEAD
CC ICD GEN REPLACE
CC ICD INS W/LEADS
CC ICD LEAD TEST ONLY
CC INTRACARDIAC EP 3D MAP
CC IVUS CORONARY
CC LHC FOR LV GRAM ONLY
CC LHC FOR LV GRAM ONLY, CC COR ANGIO W/LHC
CC PACE GEN REP DUAL LEAD
CC PACEMAKER ATR + VENT
CC PACEMAKER CHANGE DUAL
CC PACEMAKER CHANGE SINGL
CC PACEMAKER INSERT TEMP
CC PERICARDIOCENTISIS
CC PTLR CABG DES/PCI,SGL
CC RHC FOR LV GRAM ONLY
CC TRANS ESOPH ECHO/TEE
";
// 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/