So I'm trying to get the video id from a vimeo url using a regex.
Based on this: Get video id from Vimeo url
The following regex should do the trick:
if (preg_match("/https?:\/\/(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/", $videoLink, $id)) {
$videoId = $id[3];
}
But it isn't working, and I can't for the life of me work out why.
Is there a difference between regex in Javascript and PHP/am I misusing preg_match
? I've looked around on Stack Overflow for a while and just can't find a working regex for getting the video id from a vimeo url/embed.
There are plenty of regex out there for it, but none show their implementation.