Regular Expressions 101

Community Patterns

Youtube GET video_id

0

Regular Expression
PCRE (PHP <7.3)

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

Description

Youtube GET video_id (with unit tests - feel free to add more tests)

Submitted by anonymous - 4 years ago