// 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)(?=.{10}$)(?=.*[A-Za-z]){2,}(?=.*[0-9]){2,}(^|\s)[A-Za-z0-9]{10}($|\s)").unwrap();
let string = "AB1234567
09AR30253
0912345JL
abc12464
12345678
AABBCCAA23
12345B645 13424db67
12AB32457 123as3456
AB123456
123as3456 -123as3456 kljl
1B5W90R0 1B5W90R0 1B6-KQ0R-0
stackoverflow
thisstackoverflow
this is stackoverflow
this is stackoverflow it
this is stackedoverflow
1B6-KQ0R-0
1B6-KQ0R-0
Good morning, 1B
Please close accounts
Arthur Battersby – 1B6-KQ0R-0
Shirley Earle – 1B5-W90R-0
Thank you, 1B6KQ0R0 1B5W90R0
Brianna Toth
Administrative Assistant T: (888) 778-0356
Raymond James Ltd.
www.DoreyWealth.com <http://www.doreywealth.com/>
Victoria T: 250.405.2429 #1000-1175 Douglas Street (in CIBC Building), Victoria, BC V8W 2E1";
// 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/