Skip to content

Instantly share code, notes, and snippets.

@quantizor
Last active October 30, 2018 12:49
Show Gist options
  • Save quantizor/7451443 to your computer and use it in GitHub Desktop.
Save quantizor/7451443 to your computer and use it in GitHub Desktop.
Javascript regex to extract the ID out of YouTube, Vimeo and Instagram video URLs.
// Interactive breakdown at: https://www.debuggex.com/r/6zmlYhT6GVcEn-rh
var re = /^.*?(?:youtube\.com\/(?:watch\?v=|embed)/?|\/vimeo\.com\/|player\.vimeo\.com\/video\/|instagram\.com\/p\/)(.*?)\/?$/;
@AlejandroPerezMartin
Copy link

AlejandroPerezMartin commented Oct 17, 2018

Doesn't seem to work for me, getting this error Unexpected token |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment