// 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"(?<=\n{2}|^)(?:(?:-|\d+\.) +.*\n?)+").unwrap();
let string = "- one
some text
- should not start a list
- should start
- should continue
5. should also
6. more
5. should also
6. more
7. more
8. sdfs
9. sdfsf
10. sdfdsf
";
// 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/