- The first Regular Expression Library on the Web!

Please support RegExLib Sponsors


Regular Expression Details

Title Test Find RFC URL
A pretty decent URL matching expression. I've followed most RFC guidelines, so it'll match most anything ya throw at it (And wont match what it's not supposed to). If you see any problems with it, please email me so I can make the appropriate changes :)
Matches | | | | | |
Normal Text. | |
Author Rating: Not yet rated. r4cc00n
Your Rating
Bad Good

Enter New 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

Name: Vijay
Date: 9/25/2013 1:35:35 AM
Doesn't work with "" .

Name: Vijay
Date: 9/25/2013 1:34:46 AM
Doesn't work with "" .

Name: Vijay
Date: 9/25/2013 1:34:10 AM
Doesn't work with "" .

Title: Doesn't work with
Name: Gavin
Date: 6/21/2009 11:18:50 PM
I like this regular expression, but have found an issue with it... It doesn't work with legitimate * domains because of the single char (c in this case) being present. Had a quick play to try and resolve the issue, but my regular expression skills aren't so great I'm afraid :(

Title: False Positive
Name: Dirq
Date: 11/7/2007 4:06:13 PM
The RegEx matched: FC1.2AH4

Title: Additions
Name: John
Date: 10/14/2007 10:36:11 PM
I have found that it needed a bit of tweaking. The following url was not recognized:,%20int) This is because of the used brackets and the comma. Because this url IS valid I added the ',' ')' '(' to the regex. Also I added ^ and $ at the beginning and end respectively. Nice job this is the best basis I have found to base something on so far. My more complete regex now is: "^(([\w]+:)?//)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\,\(\)\d\w]|%[a-fA-f\d]{2,2})*)?$" without the quotes.

Title: equals sign in url
Name: Ben
Date: 8/27/2007 10:51:55 PM
Thanks for the regex, it's very helpful. I noticed it's not matching the following: It matches up until the equals sign. Is this URL not RFC compliant?

Name: James
Date: 8/20/2007 6:33:13 AM
Doesn't match ""

Title: If http(s):// is required, and user:pass@ is not to be allowed...
Name: bcire
Date: 4/30/2007 8:36:40 AM
...try this... ((https?):\/\/){1}(([\d\w]|%[a-fA-f\d]{2,2})+(([\d\w]|%[a-fA-f\d]{2,2})+)?)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?

Title: Matches e-mails
Name: Jonathon
Date: 2/25/2007 11:50:33 AM
@Anonymous, works fine in preg_replace() under PHP 5.2.1 for me. @r4cc00n, your regex matches e-mail addresses like Not sure if that was your intention, but probably isn't for most people; should at least put that in your description.

Title: doesn't work in PHP
Name: Anonymous
Date: 2/23/2007 12:56:32 AM
This particular expression throws an Unknown modifier error while using the preg_match() function.

Title: IDNA missing
Name: André
Date: 1/3/2007 11:03:41 AM
Hi, you really wrote a fantastic regex for URL-validation but IDNA´s are missing, which includes at least following characters: á à ă â å ä ã ą ā æ ć ĉ č ċ ç ď đ é è ĕ ê ě ë ė ę ē ğ ĝ ġ ģ ĥ ħ í ì ĭ î ï ĩ į ī ı ĵ ķ ĺ ľ ļ ł ń ň ñ ņ ŋ ó ò ŏ ô ö ő õ ø ō œ ĸ ŕ ř ŗ ś ŝ š ş ť ţ ŧ ú ù ŭ û ů ü ű ũ ų ū ŵ ý ŷ ÿ ź ž ż ð þ maybe you´ll update your regex? :)

Title: against RFC url
Name: Wine
Date: 6/2/2006 3:13:24 AM
Wine SOS. Powerful Wine Support Formula.

Copyright © 2001-2019, | ASP.NET Tutorials