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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find YouTube Video Link Verifier + ID puller
Expression
(?:[hH][tT]{2}[pP][sS]{0,1}:\/\/)?[wW]{0,3}\.{0,1}[yY][oO][uU][tT][uU](?:\.[bB][eE]|[bB][eE]\.[cC][oO][mM])?\/(?:(?:[wW][aA][tT][cC][hH])?(?:\/)?\?(?:.*)?[vV]=([a-zA-Z0-9--]+).*|([A-Za-z0-9--]+))
Description
Verifies YouTube video links AND pulls the video ID from them in a matching group. Works with all capitalizations. It also matches the WHOLE link but sorts the video ID into a group. Works with JavaScript, PHP and Python. (Not tested with any other Regex engine) WARNING: youtu.be links have their ID group as the second group.
Matches
http://www.youtube.com/watch?v=something | https://www.youtube.com/watch?v=something | http://youtu.BE/something | https://www.YOUTUBE.com/watch?en=gb&vari=abc&v=something&another=yes
Non-Matches
http://www.anothersite.com/watch?v=something | http://www.youtube.com/wat?v=something
Author Rating: The rating for this expression. Billy Venner
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