Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^https:\/\/(?:www\.)?(?:youtube(?:-nocookie)?\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([\w-]+)(?:\?.+)?$
/
gm

Description

Tested in 2024 with various share/embed methods on YouTube video page

Submitted by doseofted - a month ago