Skip to content

Instantly share code, notes, and snippets.

@blairanderson
Created April 21, 2015 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blairanderson/b264a15a8faaac9c6318 to your computer and use it in GitHub Desktop.
Save blairanderson/b264a15a8faaac9c6318 to your computer and use it in GitHub Desktop.
Youtube URL ID Regex - http://rubular.com/r/t64qPkc0Lh
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]
@Ladazprahy
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment