Regular Expressions 101

Community Patterns

YouTube Embed Video & Playlist from URL

2

Regular Expression
ECMAScript (JavaScript)

/
(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 - 9 years ago