// 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)^SCHEDULE(?:.(?!^END$))*?#\/[^\r\n]*E\r?\n(?:(?!^$).)*?[ \t]*NOP$.*?^END$").unwrap();
let string = "
SCHEDULE MASTERAGENTS#KA0HM00_LEASE
DESCRIPTION \"Added by composer.\"
:
CLA0HDST01#/KA0H/KA0HM00_LEASE/KA0HM010_LEASE_AFT
FOLLOWS KA0HM003_LEASE
FOLLOWS KA0HM007_LEASE
CLA0HDST01#/KA0H/KA0HM00_LEASE/KA0HM006_LEASE
FOLLOWS KA0HM004_LEASA
NOP
MASTERAGENTS#/KA0H/KA0HM00_LEASE/KA0HM00SLEASE
CLA0HDST01#/KA0H/KA0HM00_LEASE/KA0HM003_LEASE
CLA0HDST01#/KA0H/KA0HM00_LEASE/KA0HM002_LEASE
FOLLOWS KA0HM001_LEASE
CLA0HDST01#/KA0H/KA0HM00_LEASE/KA0HM001_LEASE
FOLLOWS KA0HM00S_LEASE
MASTERAGENTS#/KA0H/KA0HM00_LEASE/KA0HM00E_LEASE
FOLLOWS KA0HM010_LEASE_AFT
CLA0HDST01#/KA0H/KA0HM00_LEASE/KA0HM004_LEASE
FOLLOWS KA0HM002_LEASE
CLA0HDST01#/KA0H/KA0HM00_LEASE/KA0HM009_LEASE
FOLLOWS KA0HM004_LEASE
END
";
// 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/