// 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"(?:(f|F)((a|A)(X|x))?(?:\s?(\-|\:)?\s?))(?:\s?[0-9\+\.\(\)\/\\\-]\/?\\?\s?){7,30}(*SKIP)(*FAIL)|(?:\s?[0-9\+\.\(\)\/\\\-]\/?\\?\s?){7,30}").unwrap();
let string = "PO BOX number 1234, CA - 3265 TEL: +1-200-200-2000 FAX: +1-200-200-2001
PO BOX number 1234, CA - 3265 Service: +1-200-200-2002 \\ +1-200-200-2022 F : +1-200-200-2003
PO BOX number 1234, CA - 3265 care: +1-200-200-2004 f : +1-200-200-2005
PO BOX number 1234, CA - 3265 fire: +1-200-200-2006 fax : +1-200-200-2007
PO BOX number 1234, CA - 3265 help: +1-200-200-2008 fax - +1-200-200-2009
PO BOX number 1234, CA - 3265 fax : (+123)-4567890 \\ (+123)-4567891
(?:(f|F)((a|A)(X|x))?";
// 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/