url = "http://www.youtube.com/watch?v=NLqASIXrVbY"
VID_REGEX = /(?:youtube(?:-nocookie)?\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/
url.match(VID_REGEX)[1]
Created
April 21, 2015 18:12
-
-
Save blairanderson/b264a15a8faaac9c6318 to your computer and use it in GitHub Desktop.
Youtube URL ID Regex - http://rubular.com/r/t64qPkc0Lh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.youtube.com/watch?v=r-XRELhBS5A