blairanderson
4/21/2015 - 6:12 PM

Youtube URL ID Regex - http://rubular.com/r/t64qPkc0Lh

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]