// 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"(?mi)^(.{20})[^.]{4,}(.*)$").unwrap();
let string = "1.1234567890.ab
2.123456789012345678901.ab
3.1234567890123456789012.ab
4.12345678901234567890123.ab
5.123456789012345678901234.ab
6.1234567890123456789012345.ab
7.12345678901234567890123456.ab
8.123456789012345678901234567890.ab
9.123456789012345678901234567890.1234567890123456.7890.ab
0.123456789012345678901234567890.12345678901.234567890....abcdef012345
12345678901234567890123456789012345678901234567890";
// 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/