// 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{8,9}\d{1,2}\s{2}\|\s{9,10}\d{1,2}\s{2}\|\s{9,10}\d{1,2}$").unwrap();
let string = " 12 | 11 | 5
13 | 3 | 13
5 | 16 | 3
15 | 2 | 20
8 | 5 | 16
4 | 12 | 3
20 | 1 | 14
9 | 1 | 1
15 | 13 | 14
15 | 1 | 1
18 | 15 | 5
5 | 1 | 18
13 | 9 | 8
16 | 1 | 1
5 | 5 | 14
7 | 17 | 10
8 | 13 | 20
12 | 2 | 20
8 | 14 | 3
14 | 11 | 18
6 | 11 | 14
19 | 12 | 3
8 | 7 | 13
8 | 3 | 20";
// 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/