Return to Snippet

Revision: 26411
at April 27, 2010 16:02 by nkm


Initial Code
/http:\/\/(?:youtu\.be\/|(?:[a-z]{2,3}\.)?youtube\.com\/watch(?:\?|#\!)v=)([\w-]{11}).*/gi

Initial URL


Initial Description
PCRE that matches any kind of YouTube URL and catches its video ID. It supports three kinds of URL: the classic (?v=), the AJAXed one (#!v=) and the short version (youtu.be). It also supports international URLs.

Tested with Javascript and PHP.

Initial Title
YouTube URL matcher, video ID catcher

Initial Tags
url, javascript, php, video, regexp

Initial Language
Regular Expression