Created
October 28, 2013 10:50
-
-
Save krebernisak/7194858 to your computer and use it in GitHub Desktop.
From http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url
This file contains 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 youtube_parser(url) { | |
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/; | |
var match = url.match(regExp); | |
if (match && match[7].length === 11) { | |
return match[7]; | |
} else { | |
alert("Url incorrecta"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment