Regular Expressions 101

Community Patterns

Youtube Regex

1

Regular Expression
PCRE (PHP <7.3)

/
http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/|.*\&v\=|.*\/embed\/)([\w\-]+)
/
gm

Description

To get video id from different formats

Submitted by bux - 8 years ago