I have a PHP regular expression I'm using to get the YouTube video code out of a URL.
I'd love to match this with a client-side regular expression in JavaScript. Can anyone tell me how to convert the following PHP regex to JavaScript?
preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=embed/)[^&\n]+|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $url, $matches);
Much appreciated, thanks!
/.*(?:youtu.be\/|v\/|e\/|u\/\w\/|embed\/|\?v=|\&v=)([^#\&\?]*).*/
Stema does provide some good insights in his answer though so I have accepted it. – Chris Nolet Feb 16 '12 at 14:25