RegexBench

← Library

YouTube video IDs

Pull the 11-char id from common YouTube URLs.

Pattern

/(?:youtu\.be\/|v=)([A-Za-z0-9_-]{11})/

Sample text

https://youtu.be/dQw4w9WgXcQ
https://www.youtube.com/watch?v=dQw4w9WgXcQ
https://example.com/v=notyoutube
Test this pattern in the editor

Related patterns