The following code is used to get Youtube video ids in order to get a thumbnail image.
What is the reasoning behind the first regular expression and what is it doing
Ok, I did some fishing around and came accross this regex. It should suit the purpose described above.
youtu(?:\.be|be\.com)/(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)
From: C# regex to get video id from youtube and vimeo by url
And: http://forrst.com/posts/Automatic_YouTube_Thumbnails_with_PHP_and_Regex-uta