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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find URI checker
Expression
#^([a-z0-9+\-.]+):([/]{0,2}([a-z0-9\-._~%!\$&'\(\)\*+,;=:]+@)?([\[\]a-z0-9\-._~%!\$&'\(\)\*+,;=:]+(:[0-9]+)?))([a-z0-9\-._~%!\$&'\(\)\*+,;=:@/]*)(\?[\?/a-z0-9\-._~%!\$&'\(\)\*+,;=:@]+)?(\#[a-z0-9\-._~%!\$&'\(\)\*+,;=:@/\?]+)?#i
Description
This is a Perl regular expression which matches any valid URI. I've extensively tested it (with the help of Wikipedia, and the actual URI specification written by Sir Tim Burners Lee himself), and it seems to work in all cases. Whether it will actually work to validate a URI is questionable... But any URI that is valid, will match. Including those with IPv6 addresses.
Matches
ftp://ftp.is.co.za/rfc/rfc1808.txt | http://www.ietf.org/rfc/rfc2396.txt | ldap://[2001:db8::7]/c=GB?objectClass?one | mailto:[email protected] | news:comp.infosystems.www.servers.unix | tel:+1-816-555-1212 | telnet://192.0.2.16:80/ | urn:oasis:names:specification:docbook:dtd:xml:4.1.2
Non-Matches
asdf?fdjdf:blah | dskjf:///////blah | google.com
Author Rating: The rating for this expression. Colin Griffith
Source Myself
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