// 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)(?:(?:http|https):\/\/)?(?:www.|m.)?facebook.com\/(?!home.php)(?:(?:\w)*#!\/)?(?:pages\/)?(?:[?\w\-]*\/)?(?:profile.php\?id=(?=\d.*))?([\w\.-]+)").unwrap();
let string = "http://www.facebook.com/jquery2dotnet
http://www.facebook.com/some.user
https://www.facebook.com/#!/my_page_id
http://www.facebook.com/pages/test
http://www.facebook.com/pages/test/123
https://www.facebook.com/#!/page_with_1_number
http://www.facebook.com/bounce_page#!/pages/test-Url/12345
https://www.facebook.com/bounce_page#!/my_page_id?v=app_1123325
https://www.facebook.com/notes/hyperarts-web-design
http://www.facebook.com/test.username
https://www.fb.me/jquery2dotnet
http://www.facebook.com/
http://m.facebook.com/home.php
http://m.facebook.com/test.username
https://mbasic.facebook.com/home.php?_rdr";
// 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/