Skip to content

Instantly share code, notes, and snippets.

@greg606
Created September 10, 2012 15:31
Show Gist options
  • Save greg606/3691559 to your computer and use it in GitHub Desktop.
Save greg606/3691559 to your computer and use it in GitHub Desktop.
get youtube video id
function parse_youtube_url(url){
var regExp = /http[s]?:\/\/(?:[^\.]+\.)*(?:youtube\.com\/(?:v\/|watch\?(?:.*?\&)?v=|embed\/)|youtu.be\/)([\w\-\_]+)/i;
var match = url.match(regExp);
if (match&&match[1].length==11){
return match[1];
}else{
alert("incorrect url");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment