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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Yet another URI checker
Expression
^([a-zA-Z]+)://([a-zA-Z0-9_\-]+)((\.[a-zA-Z0-9_\-]+|[0-9]{1,3})+)\.([a-zA-Z]{2,6}|[0-9]{1,3})((:[0-9]+)?)((/[a-zA-Z0-9_\-,.;=%]*)*)((\?[a-zA-Z0-9_\-,.;=&%]*)?)$
Description
Checks whether the entered string looks like a URI, with a specified protocol. Optionally, you can add the port number, and some GET variables. The control is quite loose, but it's a choice of mine. Comments and corrections are welcome.
Matches
this://is.accepted.com/?and=it&sO=K | this://is.accept.ed?too= | and://also.this.one:12/?is=right
Non-Matches
this.is.NOT.accepted | neither://this.is&one | abs://olut.ely.no:way
Author Rating: Not yet rated. Claudio Di Ciccio
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: Some valid URIs don't validate
Name: Tynach
Date: 1/19/2012 12:21:02 AM
Comment:
Hi, I noticed you did a URI checker as well. I did mine in sort of a... Well, I didn't understand regular expressions, so I figured the most difficult regex possible would be for a URI, and forced myself to learn. Anyway, there are some very WEIRD URIs in the documentation dealing with the URI scheme, and it took me a long time to get a regex that matched all of them. The regex I finally came up with is here: http://regexlib.com/REDetails.aspx?regexp_id=3246 Some of the weirder URIs in the URI scheme documentation, I've put in the list of 'Matches' there. It's interesting to note, that the last two of your example non-matches actually match with my regex - and they both may very well be valid URIs - if very non-standard. Of my list of ones that do match (that should match), your regular expression only manages to match 3 of them - the FTP, HTTP, and Telnet ones. I saw you welcomed comments and corrections, so I figured I ought to post - though I kinda doubt you'll see this...


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