// 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)^\d+\.\s*ABC[^\S\n]*(?:\n.+)*").unwrap();
let string = "1. Hello world
1.1 bla bla bla
1.2 more bla bla
1.3 even more bla bla ABC
2. ABC
2.1 hello ABC
2.2 bla bla bla
3. XYZ
3.1 bla bla
3.2 more bla bla
3.3 even more bla bla
1. Hello world
1.1 bla bla bla
1.2 more bla bla
1.3 even more bla bla ABC
2. XYZ
2.1 bla bla
2.2 more bla bla
2.3 even more bla bla
3. MNO
3.1 hello MNO
3.2 bla bla bla
4. ABC
4.1 hello ABC
4.2 bla bla bla";
// 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/