// 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"(?:https?:\/\/)?(?:www\.)?facebook\.com\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[\w\-]*\/)*?(?:profile.php\?id=(?=\d.*))?([\w\-]*)?(?:[\w\-\.]*)?").unwrap();
let string = "https://facebook.com/vietphu.nguyen.7?rc=p&refid=52&__tn__=R
https://facebook.com/shunchina?rc=p&refid=52&__tn__=R
https://facebook.com/phuocnguyen.nguyen.16568?rc=p&refid=52&__tn__=R
https://facebook.com/profile.php?id=100004404017311&rc=p&refid=52&__tn__=R";
// 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/