// 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"(?im)^([\d,*\/-]*\s+){3}(\(LW\)|[\d,*?\/-]+)\s+((?:JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC|[\d,*?\/#-]+)(?:\s*,\s*(?:JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC|[\d,*?\/#-]+))*)\s*((?:SUN|MON|TUE|WED|THU|FRI|SAT|\(LW\)|[\d*?\/#-]+)(?:\s*(?:SUN|MON|TUE|WED|THU|FRI|SAT|\(LW\)|[\d*?\/#-]+))*)([\d,*\/#-]*)$").unwrap();
let string = "0/5 14,18,3-39,52 * ? JAN,MAR,SEP MON-FRI 2002-2010
0/5 14,18,3-39,52 * ? JAAN,MAR,SEP MON-FRI 2002-2010";
// 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/