Regular Expressions 101

YouTube Embed Video & Playlist from URL

Open Workspace
  • JavaScript
  • Substitution
2

Regular Expression

/
(https?:\/\/)?(www.)?(youtube\.com|youtu\.be|youtube-nocookie\.com)\/(?:embed\/|v\/|watch\?v=|watch\?list=(.*)&v=)?((\w|-){11})(&list=(\w+)&?)?
/
i

Description

It gets the playlistID and the videoID to conform the embed URL from the video URL

Submitted by @rubenlopezgea