Return to Snippet

Revision: 62239
at February 11, 2013 07:31 by slimITTN


Initial Code
var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/;
var match = url.match(regExp);
if (match&&match[2].length==11){
    return match[2];
}else{
    //error
}

Initial URL
http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url

Initial Description
This snippets show how to extract the video id of a youtube video from its URL

Initial Title
Youtube ID from URL

Initial Tags
url, video

Initial Language
JavaScript