// 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)^(0{0,2}\+?389[\s./-]?)(\(?[0]?[7-7][0-9]\)?[\s./-]?)([2-9]\d{2}[\s./-]?\d{3})$").unwrap();
let string = "+389 70 123 456
389-71-234-567
389-071-234-567
389-0071-234-567
00389.72.345.678
+389/73/456/789
389 75 123456
389 76-234-567
+38970123456
38971234567
0038972345678
+38973456789
38975123456
38976234567
38980123456
+38982123456
+389 70 123-456
+389 70 323-456
389(71)234.567
389(071)234.567
00389/723-456-78
+389 (73) 456.789
389 75 123/456
389 76-234.567
389.80.123.456
389.(080).123.456
+389-82-123-456
00389 (81) 234-56
389/931-234-56
+3899512-3456
00389(95)12.345
389/10-123-456
389 11-123/456
+389 12.123-456";
// 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/