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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Validate URL
Expression
^((http://)|(https://))((([a-zA-Z0-9_-]*).?([a-zA-Z0-9_-]*))|(([a-zA-Z0-9_-]*).?([a-zA-Z0-9_-]*).?([a-zA-Z0-9_-]*)))/?([a-zA-Z0-9_/?%=&+#.-~]*)$
Description
A regex I came up with for validating urls, didn't test thoroughly but seems to do the trick.
Matches
http://sportsalert.net, https://www.sportsalert.net, http://sportsalert.net.uk, http://sportsalert.net/index.html, http://sportsalert.net/subdirectory, http://sportsalert.net?var1=param1&var2=param2
Non-Matches
www.sportsalert.net, http://.sportsalert.net, http://sportsalert..net
Author Rating: The rating for this expression. Justin Toth
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

Title: Bad validation
Name: MDG
Date: 10/7/2007 10:12:38 AM
Comment:
It accepts http:// as a link and http://www.foo as a link. Not really useful. SHould require at lease a site name and a .something.


Title: Problem with the URL validation
Name: Rex Steve
Date: 9/28/2007 4:13:48 AM
Comment:
What if the Url contains a : in querystring argument.


Title: Problem with the URL validation
Name: Rex Steve
Date: 9/28/2007 2:48:38 AM
Comment:
What if the Url contains a : in querystring argument.


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