Created
May 26, 2019 21:39
-
-
Save grvoyt/e7d1545553cc173d1358defbdecf2ba1 to your computer and use it in GitHub Desktop.
Js code get youtube id from urls
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); | |
return (match&&match[7].length==11)? match[7] : false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment