// 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"(?iu)^(http(s)?:\/\/)?(www\.)?linkedin\.([a-z]+)\/in\/[\p{L}\p{N}\p{M}_-]{3,100}\/?$").unwrap();
let string = "http://linkedin.com/in/mariam-el-maghrabi-b20b88167
https://www.linkedin.com/in/bhupad-rathi-33b69118b
https://www.linkedin.com/in/hassen-hamza-b7350013/
https://www.linkedin.com/in/safna-senna-1781a8193/
https://www.linkedin.com/in/balaji-mutyala-7b9a3916b/
https://www.linkedin.com/in/adnan-alkeba/
https://www.linkedin.com/in/ahmed-mouniir/
https://www.linkedin.com/in/louay-alshoum
https://linkedin.com/in/exyfi
https://www.linkedin.com/in/mohammed-elsheikh-889353102/
https://www.linkedin.com/in/%C5%9Fahin-e%C4%9Filmez-856631114/";
// result will be a tuple containing the start and end indices for the first match in the string
let result = regex.captures(string);
let (start, end) = match result {
Some((s, e)) => (s, e),
None => {
// ...
}
};
println!("{}", &string[start, end]);
}
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/