Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

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

Description

For embeding, replace with //www.youtube.com/embed/$3?list=$2$6

Submitted by @rubenlopezgea - 10 years ago