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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^(ht|f)tp(s?)\:\/\/[a-zA-Z0-9\-\._]+(\.[a-zA-Z0-9\-\._]+){2,}(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$
Description
Cheap and cheerful URL checker. Requires a http/https/ftp at the start and will then allow anything starting with at least a <something>.<something>.<something> then valid characters separated by dots and slashes
Matches
http://www.thedaddy.org | http://forum.thedaddy.org/index.html | ftp://hows.it.going_buddy/checkit/o
Non-Matches
www.thedaddy.org | http://hello | ftp://check.it
Author Rating: The rating for this expression. John Main
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: Port numbers not allowed
Name: Roger
Date: 5/25/2005 2:34:18 PM
Comment:
This expression fails to match a url with a port number specification. For example, http://www.mydomain:8080/somedir will fail


Title: Try mine
Name: Justin Perkins
Date: 4/18/2005 8:27:29 PM
Comment:
Check the comments before posting Antonio, mine matches your URI just fine.


Title: Needs improvement
Name: antonio
Date: 4/11/2005 7:12:52 PM
Comment:
FAILED: http://host.domain.com/folder/document.html?var=value


Title: Great Pattern, and...
Name: Justin Perkins
Date: 3/7/2005 11:59:58 PM
Comment:
The pattern by John Main does not match anything after a ?, so any querystring will be lopped off. Use the original with the additional suggestions by Brian and Neik (assuming you do an HtmlEncode() on the string before matching)... (ht|f)tp(s?)\:\/\/[a-zA-Z0-9\-\._]+(\.[a-zA-Z0-9\-\._]+){2,}(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+=&%\$#_]*)?


Title: This works better
Name: John Main
Date: 3/6/2005 6:39:40 AM
Comment:
^(ht|f|Ht|F)(tp)(s?)\:\/\/([a-zA-Z0-9\-_~]+)(\.[a-zA-Z0-9\-\._~]+)+(\/?)([^\">\<\s]*)$


Title: HTML Entities
Name: Niek
Date: 3/5/2005 9:32:44 AM
Comment:
It also doesn't support html entities. All special characters on HTML pages should be entities, and so & should be &amp; (only one seen in URL's) If you use this with URL's with entities, change & to (&amp;)


Title: Slashes
Name: John Main
Date: 3/3/2005 12:14:45 PM
Comment:
If you're getting a rejected character then inserting a backslash before it normally does the trick


Title: Querystring Probs
Name: Brian
Date: 3/3/2005 10:05:34 AM
Comment:
I was having querystring probs, its not alowing the = as a valid charactor. I just added it after +.. ^(ht|f)tp(s?)\:\/\/[a-zA-Z0-9\-\._]+(\.[a-zA-Z0-9\-\._]+){2,}(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+=&%\$#_]*)?$


Title: MS
Name: SHEETAL
Date: 2/24/2005 1:58:00 AM
Comment:
Really Nice


Title: Mr
Name: Sameer
Date: 2/24/2005 1:56:45 AM
Comment:
its good.


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