RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Extract YouTube ID
Expression
(?:[Yy][Oo][Uu][Tt][Uu][Bb][Ee]\.[Cc][Oo][Mm]/watch\?v=)([\w-]{11})
Description
.NET 3.5 Tested. Used to extract the YouTubeID from a fully qualified YouTube URL. Dim _Regex As New Regex("(?:[Yy][Oo][Uu][Tt][Uu][Bb][Ee]\.[Cc][Oo][Mm]/watch\?v=)([\w-]{11})", RegexOptions.IgnoreCase Or RegexOptions.Compiled) Dim _RegexMatch As Match = _Regex.Match("http://www.youtube.com/watch?v=pW2GSdxxwDg") Dim _YouTubeVideoID As System.String = _RegexMatch.Groups(1).Value
Matches
http://www.youtube.com/watch?v=pW2GSdxxwDg | http://www.youtube.com/watch?v=-7P7_kxZQ5I | http://www.youtube.com/watch?v=7sPKHwsupmQ&playnext=1&list=PL40CB7986D1A9A285 | http://www.youtube.com/watch?v=r-di4gJvq4Q&feature=channel_video_title
Non-Matches
http://www.youtu.be/watch?v=pW2GSdxxwDg
Author Rating: The rating for this expression. Charlie Seitz
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials