// 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)^(?:.*?\bRationale-|Normal|List Paragraph\t(?:\d+\)[ \t]*)?)[ \t]*\K.*").unwrap();
let string = "List Paragraph 36) Rationale-1 - Details on the context:
List Paragraph 37) None.
Normal
List Paragraph 38) 2 - Statement complements:
List Paragraph 39) Blablablabla
List Paragraph (1) Blablablabla
List Paragraph (2) Blablablabla
List Paragraph (3) Blablablabla
List Paragraph (4) Blablablabla
List Paragraph (5) Blablablabla
List Paragraph (6) Blablablabla
List Paragraph (7) Blablablabla
Normal
List Paragraph 40) Blablablabla
Normal
List Paragraph 41) 3 - Statement justification:
List Paragraph 42) Blablablabla
Normal
List Paragraph 43) Blablablabla
List Paragraph 44) Blablablabla
List Paragraph 45) Blablablabla
List Paragraph 46) Attached Files: Rationale-
Normal";
// 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/