I’ve been working on a Youtube and Vimeo embed code parser, I’m trying to solve problem by using regular expressions.
I’ve found two patterns and they’re working with eregi() function but unfortunately doesn’t work with preg_match(). Gives “Delimiter must not be alphanumeric or backslash” error.
How can I convert these patterns from POSIX to PCRE?
For Youtube;
\/v\/(.{11})|\/embed\/(.{11})
For Vimeo;
player\.vimeo\.com\/video/([0-9]*)"
This is for youtube:
$pattern = '/\/v\/(.{11})|\/embed\/(.{11})/';And that’s for Vimeo:
$pattern = '/player\.vimeo\.com\/video\/([0-9]*)/';When using PCRE, make sure, you enclose the expression in
/expression/(slashes), and escape also all the/. I noticed you do sometimes, sometimes you don’t …