// 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)^(?<nr_classe>(\d{4,}))([\x20\t\-]{1,}|[a-zA-Z]|$)").unwrap();
let string = "250156304 - 6 ANO A INTEGRAL ANUA
250156445 - 7 ANO A INTEGRAL ANUA
250794211 - 2ª SERIE A INTEGRAL ANUA
250794484 - 2ª SERIE B INTEGRAL ANUA
250795069 - 3ª SERIE A INTEGRAL ANUA
250795291 - 3ª SERIE B INTEGRAL ANUA
250797255 - 6 ANO A INTEGRAL ANUA
250797644 - 7 ANO A INTEGRAL ANUA
250797800 - 7 ANO B INTEGRAL ANUA
250798147 - 8 ANO A INTEGRAL ANUA
250798493 - 9 ANO A INTEGRAL ANUA
250798725 - 9 ANO B INTEGRAL ANUA
251327540 - 8 ANO A TARDE ANUA
251327755 - 8 ANO B TARDE ANUA
251328951 - 7 ANO A TARDE ANUA
251329173 - 7 ANO B TARDE ANUA
251329173 -7 ANO B TARDE ANUA
251331013 - 6 ANO A TARDE ANUA
252381546 - 6074 - INFORMATICA PARA INTERNET - 1ª SERIE NT MANHA ANUA";
// 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/