UPDATED October 2018
Neither of the two existing REGEX proposals worked for me, and there are more visible cases than the ones considered.
Here's my REGEX Proposal:
^(?:(?:https?:)?\/\/)?(?:www\.)?facebook\.com\/[a-z\.]+\/videos\/(?:[a-z0-9\.]+\/)?([0-9]+)\/?(?:\?.*)?$
^(?:(?:https?:)?\/\/)?(?:www\.)?facebook\.com\/[a-zA-Z0-9\.]+\/videos\/(?:[a-zA-Z0-9\.]+\/)?([0-9]+)
I ignored video.php, I think it's old enough to safely ignore it.
Matches:
https://www.facebook.com/aguardos.nocturnos/videos/vb.1614866072064590/1828228624061666/?type=2&theater
https://www.facebook.com/aguardos.nocturnos/videos/vb.1614866072064590/1828228624061666?type=2&theater
https://www.facebook.com/aguardos.nocturnos/videos/1828228624061666/
https://www.facebook.com/latavernadelssomnis/videos/1609038972452561/?hc_ref=NEWSFEED
//www.facebook.com/aguardos.nocturnos/videos/1828228624061666/
https://facebook.com/aguardos.nocturnos/videos/1828228624061666/
http://www.facebook.com/aguardos.nocturnos/videos/1828228624061666/
www.facebook.com/aguardos.nocturnos/videos/18282286240612666/
facebook.com/aguardos.nocturnos/videos/18282286240612666/
https://www.facebook.com/aguardos.nocturnos/videos/1828228624061666
https://www.facebook.com/WEAU13News/videos/588612391555522/UzpfSTEzMzAzMDk4NjM6MTAyMTMxMjMzNDE3ODE0MTI/
I do not own nor I have watched any of the videos. I just picked random ones that were on my facebook feed.
Groups
- Video ID.
Gotchas
One of the most common Facebook video formats is more complex than I'd like it to be and matching every case perfectly with REGEX would probably lead to a very messy query.
https://www.facebook.com/RolandGarros/videos/10155404760334920/FOO (valid)
https://www.facebook.com/RolandGarros/videos/FOO/10155404760334920 (valid)
https://www.facebook.com/RolandGarros/videos/10155404760334920/FOO/FOO (invalid)
The way this one seems to work is by retrieving the numeric value in the first or second part after videos/.
https://www.facebook.com/RolandGarros/videos/10155361533554920/1015536153355492134
What about this one where two valid numeric values are involved? It seems like the second one is the one that will prevail.
For this reason the REGEX solution above was softened1 to match only the beginning of the Facebook URL, up to the video group that we're looking for. Considering that your goal's probably to extract the video ID, rather than verify the URL, I think that's a valid trade-off. At the end of the day, you'll be checking the video either way (either through API or scrapping) to extract the video information since an ID doesn't mean that the video exists or it's public.
1 Not just softened, but also improved to match the test case format.
Test
You can easily test it yourself @ Regex101