Ashok Padmanabhan Ashok Padmanabhan - 4 months ago 28 Question

Is there a regex to match Facebook urls that contain videos or photos?

Is there a regex to match faebook url that have photos and/or videos? From what I can see such urls vary considerably. For example:

The first contains a video and the 2nd a photo.

I have a regex for FB posts:

That regex works fine when I embed a post like
but not for things that have photo or video. So is it possible to have a regex for those posts with video or photos? This is all for the purposes of embedding FB posts.


This regex handles almost all facebook urls:


It just doesnt handle something like