// 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)^(?=\S{8,20}$)(?=\D*\d)(?![0-9_]).{6,18}?(.)\1$").unwrap();
let string = "+234567899
a_1de*Gg
xy1Me*__
!41deF_hij2lMnopq3ss
C234567890123$^67800
*5555555
sDF564zer\"\"
!!!!!!!!!4!!!!!!!!!!
abcdefghijklmnopq9ss
a_1+Eff
B41def_hIJ2lmnopq3stt
abCDefghijklmnopqrss5
A_4 e*gg
__1+Eff
841DEf_hij2lmnopq3stt
a_1+eFg
b41DEf_hij2lmnopq3st
abCDefghijklmnopqrss
abcdef+++dF
!!!!!!!!!!!!!!!!!!!!
";
// 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/