// 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)(?:(?:www\.facebook\.com\/(?:(?:(?:video\.php)|(?:watch\/))\?v=\d+|(?:[0-9a-zA-Z-_.]+\/(?:(?:video|(post))(?:s))\/)(?:\d+|(?:\w+\.\d+\/)\d+)))|(?:fb\.watch\/(?:\w|-)+)\/?)").unwrap();
let string = "https://fb.watch/2xoYhkRbF255
https://fb.watch/2xoYhkRbF2/
https://fb.watch/2xo-_v7K6Vj/
https://www.facebook.com/myntpc/videos/842675369629973
https://www.facebook.com/michelle.huang.108889/posts/10157993447446172
https://www.facebook.com/nikololok/videos/t.100000216422619/10153335471682286/?type=2
https://www.facebook.com/something/videos/vb.100001360760001/1371428966245002/?type=2&video_source=user_video_tab
https://www.facebook.com/video.php?v=250367532879495
https://www.facebook.com/watch/?v=250367532879495
<iframe src=\"https://www.facebook.com/plugins/post.php?href=https://fb.watch/2xoYhkRbF2/&width=500&show_text=true&appId=290536511140551&height=526\"width=\"500\"height=\"526\"style=\"border:none;overflow:hidden\"scrolling=\"no\"frameborder=\"0\"allowfullscreen=\"true\"allow=\"autoplay;clipboard-write;encrypted-media;picture-in-picture;web-share\"></iframe>
<iframesrc=\"https://www.facebook.com/plugins/post.php?href=https://www.facebook.com/michelle.huang.108889/posts/10157993447446172&width=500&show_text=true&appId=290536511140551&height=204\"width=\"500\"height=\"204\"style=\"border:none;overflow:hidden\"scrolling=\"no\"frameborder=\"0\"allowfullscreen=\"true\"allow=\"autoplay;clipboard-write;encrypted-media;picture-in-picture;web-share\"></iframe>
<div class=\"fb-post\" data-href=\"https://www.facebook.com/DailyMailVideo/posts/3729983233749236\" data-width=\"500\" data-show-text=\"true\"><blockquote cite=\"https://www.facebook.com/DailyMailVideo/posts/3729983233749236\" class=\"fb-xfbml-parse-ignore\"><p>A new set of eleph-antlers!</p>由 <a href=\"https://www.facebook.com/DailyMailVideo/\">Daily Mail Video</a> 發佈於 <a href=\"https://www.facebook.com/DailyMailVideo/posts/3729983233749236\">2021年1月5日 星期二</a></blockquote></div>
<iframesrc=\"https://www.facebook.com/plugins/video.php?height=316&href=https://www.facebook.com/1243823171/videos/10217863771006297/&show_text=false&width=560\"width=\"560\"height=\"316\"style=\"border:none;overflow:hidden\"scrolling=\"no\"frameborder=\"0\"allowfullscreen=\"true\"allow=\"autoplay;clipboard-write;encrypted-media;picture-in-picture;web-share\"allowFullScreen=\"true\"></iframe>
";
// 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/