Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^(?:https?:)?\/\/(?:(?:www\.)?youtube\.com|youtu\.be)\/(?:(?:watch\?v=|user|v\/|embed\/))?([a-zA-Z0-9]+)
/
mg

Description

Works on "*youtube.com" urls, as well as "youtu.be" urls

Submitted by Lucanos - 9 years ago