// 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)(\+?(?:(84|0))(\s?[\-\u2010\u2011\u2012\u2013\u2014\u2015]?\s?)[357-9]\d{6}(?:\d{2}(?:\d{1})?)?)").unwrap();
let string = "1234567
76543211234
123456789
12345778
1234567890
+8412345678
84123456789
8412345
84123456
+1234567
+84
0123456
+84356763987
5123456
31234567
712345678
9123456789
+84-5123456
+84 5123456
05123456
0-5123456
+84 - 5123456
843378262
84337671542
84575516147
";
// 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/