Skip to content

Instantly share code, notes, and snippets.

@ohmika
Created February 18, 2019 21:01
Show Gist options
  • Save ohmika/fb7211a9972bf099944e2de8eeb1af42 to your computer and use it in GitHub Desktop.
Save ohmika/fb7211a9972bf099944e2de8eeb1af42 to your computer and use it in GitHub Desktop.
Use this regex to get the video ID of a YouTube URL
(?<=(?:v|i)=)[a-zA-Z0-9-]+(?=&)|(?<=(?:v|i)\/)[^&\n]+|(?<=embed\/)[^"&\n]+|(?<=(?:v|i)=)[^&\n]+|(?<=youtu.be\/)[^&\n]+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment