Created
June 27, 2014 17:07
-
-
Save fredchu/5c780748c85d0d773291 to your computer and use it in GitHub Desktop.
Regex for getting YouTube id from YouTube 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
var _regex = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/; | |
var videoUrl = 'http://www.youtube.com/watch?v=D1GmL_mvmwY&feature=g-high-u'; | |
// there you go~ | |
var youtubeId = videoUrl.match(_regex)[7]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment