DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Extract Youtube Video ID from URL
/* Source : http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url */
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
}
This snippets show how to extract the video id of a youtube video from its URL






Comments
Michael Molo replied on Thu, 2013/02/21 - 1:36am
http://www.gather.com/viewArticle.action?articleId=281474978263030