Regular Expressions 101

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
.*(?:(?:youtu.be\/)|(?:v\/)|(?:\/u\/\w\/)|(?:embed\/)|(?:watch\?))\??v?=?([^#\&\?]*).*
/
g

Description

Finds a YouTube video ID given a YouTube URL

Submitted by Lasnv - 8 years ago