Title |
Test
Find
Pattern Title
|
Expression |
^(((ht|f)tp(s?))\://)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+\.(com|edu|gov|mil|net|org|biz|info|name|museum|us|ca|uk)(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\;\?\'\\\+&%\$#\=~_\-]+))*$ |
Description |
Version 1.3.0: I needed a regexp to validate URL's without the ht(f)tp(s):// and include North American domains (like .us and .ca) and there didn't seem to be one available...so I created one. It will also work with ASP QueryStrings and anchor URL's. If you have a problem with the expression or have any suggestions to improve, please write me and let me know. Added .uk domain and expression now allows for URLs that contain JSP session IDs. 4/14/04 - added ability to include URLs that start with server names. |
Matches |
www.blah.com:8103 | www.blah.com/blah.asp?sort=ASC | www.blah.com/blah.htm#blah |
Non-Matches |
www.state.ga | http://www.blah.ru |
Author |
Rating:
Brad Dobyns
|
Source |
Brad Dobyns |
Your Rating |
|
Title: Four WWWW. should fail
Name: Salman
Date: 8/19/2013 8:00:37 AM
Comment:
Why it does take four(4) "W"'s instead of three. it should fail the following url wwww.gurulogics.com
Title: exclude http://
Name: PeterS
Date: 8/9/2012 5:27:33 PM
Comment:
In your description you say "validate URL's without the ht(f)tp(s):// ". I want string to pass validation only if ht(f)tp(s):// is NOT present. How can I do that?
Title: Mod to capture top level domains listed by IANA
Name: Dave A-W
Date: 11/25/2005 12:42:58 PM
Comment:
Here's a modification to capture TLD's listed by the Internet Corporation for Assigned Names and Numbers at http://www.iana.org/cctld/cctld-whois.htm
^(((ht|f)tp(s?))\://)?(www.|[a-zA-Z].)[a-zA-Z0-9\-\.]+\.(com|edu|gov|mil|net|org|biz|pro|info|name|museum|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|az|ax|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)(\:
Title: re: Don`t work...
Name: Brad
Date: 9/13/2005 12:12:58 PM
Comment:
Colonel,
In order to use the .ru domain, just add "|ru" (without quotes) after "|uk" in the RegEx. If you need any other assistance, let me know.
Title: Don`t work ...
Name: Colonel
Date: 9/11/2005 9:50:42 PM
Comment:
Hi Brad. Can you tell me how can I`m use this exp for url :
xcvxcvxvxv.ru(com) - work, but no such site...
If user input : http://www.sdfsdf.com or etc. - it`s works.
Can you help me ... I need exp for validate urls.
Thanks.
Title: re: ht(f)tp(s)://
Name: Brad
Date: 10/14/2004 9:13:42 AM
Comment:
It should already validate on all of those. What URL are you testing with? I just did a test here at the site and all three (http://, ftp://, https://) worked for me.
Title: ht(f)tp(s)://
Name: Ian
Date: 10/14/2004 4:45:04 AM
Comment:
How can I alter it to include validation for the ht(f)tp(s):// ?
Title: Updated the list of extensions
Name: Jodda
Date: 6/9/2004 6:46:25 AM
Comment:
Current list of extensions plus all extensions listed on register.com to this comments date:
ac|as|be|biz|ca|cc|com|co.il|co.uk|co.nz|co.za|com.ru|com.ph|de|dk|edu|fm|gs|gov|il|info|jp|kz|lt|ms|mil|museum|nz|net|net.nz|name|org|org.il|org.nz|org.uk|ph|pro|ro|sh|st|tc|to|tv|uk|us|vg|vu|ws|za
Title: Added just a little bit
Name: Noah
Date: 4/2/2004 11:58:33 AM
Comment:
Worked very well for me. I just added [a-z][a-z] to the end of the list of domain extensions to include countries such as .uk, like so:
[ Find] [ Edit] [ Test]
Expression: ^(((ht|f)tp(s?))\://)?(www.)[a-zA-Z0-9\-\.]+\.(com|edu|gov|m
il|net|org|biz|info|name|museum|us|ca|<b>[a-z][a-z]</b>)(\:[0-9]+)*(/($|[a-zA-
Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$
Thank you, Brad