| 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:
Colin Griffith
|
| Source |
Myself |
| Your Rating |
|
Title: Shorter version
Name: Tynach
Date: 1/24/2026 9:20:49 PM
Comment:
A shorter, non-PCRE-specific version of this would be:
"^([A-Za-z0-9+\-.]+):(\/{0,2}([!$-.0-;=A-Z_a-z~]+@)?([!$-.0-;=A-\[\]_a-z~]+(:[0-9]+)?))([!$-;=@-Z_a-z~]*)(\?[!$-;=?-Z_a-z~]+)?(#[!$-;=?-Z_a-z~]+)?$"
For some reason, I can't add another regex to my account, so I'm adding a comment instead.