Regular Expressions 101

Community Patterns

YouTube Video Id Extractor

0

Regular Expression
PCRE2 (PHP >=7.3)

/
(http(?: s) ?: \/\/(?:m.)?(?:www\.)?)?youtu(?:\.be\/|be\.com\/(?:watch\?(?:feature=youtu\.be\&)?v=|v\/|embed\/|user\/(?:[\w#]+\/)+))([^&#?\n]+)
/

Description

Extracts video id of YouTube videos. Note: will not work for playlists

Submitted by UnrealApex - 3 years ago