// 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"(?i)\b.*([a-z]\d+[a-z]|[a-z]{2,}\d|\d[a-z]{2,}).*?\b").unwrap();
let string = "These would be valid:
1234567890aA 1234567890A
123A4567890a 1234567890
A1234567890a 1234567a890
John12 a1234567890
qw123123 1a
John20 aa
20John
1aa
These would not:
1234567890A
1234567890
1234567a890
a1234567890
1a
aa";
// 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/