Regular Expressions 101

Community Patterns

1...34567...901

Community Library Entry

5

Regular Expression
ECMAScript (JavaScript)

/
(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|playlist\?|watch\?v=|watch\?.+(?:&|&);v=))([a-zA-Z0-9\-_]{11})?(?:(?:\?|&|&)index=((?:\d){1,3}))?(?:(?:\?|&|&)?list=([a-zA-Z\-_0-9]{34}))?(?:\S+)?
/
g

Description

extract video id, index, play list id from youtube URL

Submitted by anonymous - 9 years ago