// 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)((\+|\+\s|\d{1}\s?|\()(\d\)?\s?[-\.\s\(]??){8,}\d{1}|\d{3}[-\.\s]??\d{3}[-\.\s]??\d{4}|\(\d{3}\)\s*\d{3}[-\.\s]??\d{4}|\d{3}[-\.\s]??\d{4})").unwrap();
let string = " +61 2 8249 5000
+61 2 6122 5100
+61 2-9407 5247
+65-8233-6124
+61 412 364 923
1300 890 902
0435 569 072
8801911384785
0086-010-58732690
+ 852 2118 3893
(852) 2513 3168
(852) 2865-9898
+91-9552503220
+914042024714
+919948298078
+91 22 25094755
0124 4742300
+1 (972)273 0738
08111 90 1859
+62-21-5201214
+62 21 2995 1641
603-4270 2309
+603 7724 1199
+603-77108288
+632 8937377
(65) 6723 6888
+6596233196
+656379 2681
+65 6737 0324
82-70-7791-7100
+82 17 238 1226
82-31-478-4506
+822-6309-6366
(000)000-0000
(000)000 0000
(000)000.0000
(000) 000-0000
(000) 000 0000
(000) 000.0000
0000000000
(000)0000000
(000)000-0000
(000)000 0000
(000)000.0000
(000) 000-0000
(000) 000 0000
(000) 000.0000
000-0000
000 0000
000.0000
0000000
0000000000
(000)0000000";
// 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/