// 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)(?xi)^( (DE)?[0-9]{9}|)$").unwrap();
let string = "ATU99999999
BE0999999999
BG999999999
HR12345678901
CY99999999L
CZ12345678
DK99999999
EE123456789
FI99999999
FRXX999999999
DE999999999
EL123456789
HU12345678
IE1S23456L
IE1234567T
IE1234567TW
IE1234567FA
ESA12345678
ESZ1234567E
DE813992525";
// 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/