// 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)^([A-Z][A-HJ-Y]?\d[A-Z\d]? ?\d[A-Z]{2}|GIR ?0A{2})$").unwrap();
let string = "A1A 1AA
A1 1AA
A11 1AA
AA1 1AA
AA1A 1AA
AA11 1AA
A1A1AA
A11AA
A111AA
AA11AA
AA1A1AA
AA111AA
GIR 0AA
GIR0AA
a1a 1aa
a1 1aa
a11 1aa
aa1 1aa
aa1a 1aa
aa11 1aa
a1a1aa
a11aa
a111aa
aa11aa
aa1a1aa
aa111aa
gir 0aa
gir0aa";
// 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/