// 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)^(0|\+98)9[0-9]{9}$").unwrap();
let string = "09156987452
09908472853
09153610882365
09158645287
+9814756842
+980915874622
+989908472853
+981283547
9836587498
+986859554
+989158497858
+9812457868
02154091563214587
12409156032145
091596356478
+982654789652
023654d
5588
879 091586424569
+9878546
+9999999999999
+989153610883
0915603551555555555
";
// 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/