// 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)(\+?6)?\ ?0\ ?\d{1,2}\-?\s?\d{3,4}\s?\d{4}").unwrap();
let string = "03-2222 3333
04-222 3333
010-222 3333
011-2222 3333
011 2222 3333
+60 3-2222 3333
+60 4-222 3333
+60 10-222 3333
+60 11-2222 3333
+60 11 2222 3333
+6011 2222 3333
+6011-2222 3333
60102223333
601122223333
0102223333
01122223333
+60322223333
+6042223333
call 012-0000 0000 now";
// 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/