Title |
Test
Find
Pattern Title
|
Expression |
^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$ |
Description |
Ok here's an updated URL regex for you folks. It allows localhost and all TLDs. Feel free to add each country code individually if you want a tighter match. |
Matches |
http://site.com/dir/file.php?var=moo | https://localhost | ftp://user:[email protected]:21/file/dir |
Non-Matches |
site.com | http://site.com/dir// |
Author |
Rating:
Brian Bothwell
|
Source |
|
Your Rating |
|
Title: Still a problem
Name: Stephen P
Date: 7/27/2011 8:16:45 PM
Comment:
"Non-Matches http://site.com/dir//"
The double trailing slash like this is legitimate, as is an interior double slash like http://site.com/dir1//dir2/dir3//file.html
Title: almost perfect
Name: Tsahi
Date: 4/14/2011 4:48:48 AM
Comment:
it should be extended a bit to accept underscore in the server name part (i believe it's legal), and more characters in the password part. other than that, very good.
Title: Nice
Name: Allen
Date: 9/26/2008 1:53:44 AM
Comment:
Great! This is exactly what I am looking for.
Title: Querystrings
Name: Martin
Date: 2/1/2006 4:22:08 PM
Comment:
Doesn't seem to work with multiple query variables?
Title: Still the same bug ...
Name: SpiegS
Date: 7/11/2004 12:59:14 PM
Comment:
or is this a feature?
http://[email protected]@[email protected]
Title: Take that back
Name: Fred
Date: 7/7/2004 6:33:48 AM
Comment:
Ignore my last comment. Works now. I must have messed up the copy and paste somehow.
Title: Doesn't work for me
Name: Fred
Date: 7/7/2004 6:31:21 AM
Comment:
Throws an exception in dotnet including the test function on this site.
Title: Improvement(?)
Name: Nail
Date: 1/22/2004 1:30:09 AM
Comment:
Works more stable when added "(\/)?" at the end of pattern
Title: Underbar?
Name: Amgine
Date: 1/19/2004 12:04:58 PM
Comment:
Excellent, except... http://www.my_domain.com
Title: Pretty nice, but...
Name: Nail
Date: 1/9/2004 3:03:11 AM
Comment:
Cool, but don't understand slash at the end of path...