Skip to content

Instantly share code, notes, and snippets.

@grvoyt
Created May 26, 2019 21:39
Show Gist options
  • Save grvoyt/e7d1545553cc173d1358defbdecf2ba1 to your computer and use it in GitHub Desktop.
Save grvoyt/e7d1545553cc173d1358defbdecf2ba1 to your computer and use it in GitHub Desktop.
Js code get youtube id from urls
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