Created
September 10, 2012 15:31
-
-
Save greg606/3691559 to your computer and use it in GitHub Desktop.
get youtube video id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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