Title |
Test
Find
Pattern Title
|
Expression |
^[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$ |
Description |
Domain names:
This regular expression tests the validity of a domain or hostname. It will match any valid domain name that does not contain characters which are invalid in URLs, and which ends in .com, .org, .net, .mil, or .edu. You can add additional valid TLDs by appending the | (pipe) character and the desired TLD to the list in the parens. |
Matches |
3SquareBand.com | asp.net | army.mil |
Non-Matches |
$SquareBand.com | asp/dot.net | army.military |
Author |
Rating:
Not yet rated.
G. Andrew Duthie
|
Source |
I cobbled this together from a variety of sources that showed how to do email address regexps. The rest was experimentation. |
Your Rating |
|
Title: Really bad
Name: Rich
Date: 3/7/2018 5:58:46 PM
Comment:
This is a really bad example; limited by to a set list of TLDs, and doesn't perform proper validation against domain RFC definitions.
Title: Domain
Name: Matt
Date: 4/21/2008 4:21:30 PM
Comment:
The following is a list of all current domains separated by a pipe (|) as wikipedia has it. Note that this is designed for case insensitive regular expression evaluators. You would need to add several for case sensitive evaluations (for com you would need com, Com, COm, COM, etc) com|org|net|mil|edu|aero|arpa|asia|biz|cat|coop|info|int|jobs|mobi|museum|name|pro|tel|travel|ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|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|me|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|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sk|sl|sm|sn|sr|st|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|za|zm|zw
Title: Watch TV Satellite On Your Computer
Name: cathy
Date: 3/6/2007 6:27:51 AM
Comment:
Hey,i agree with your article
Title: do not use this
Name: user
Date: 1/28/2007 6:44:08 PM
Comment:
This does not support new domains like biz, info, museum, or the 190+ other countries in the world: .br, .uk, .cn, .in, .jp, etc.
Title: no good
Name: mrx
Date: 8/24/2006 2:52:37 PM
Comment:
Hi,
your pattern matches for example:
-domain.com
domain-.com
which are not valid domains.
Title: good
Name: sunny
Date: 7/6/2006 9:41:11 PM
Comment:
very good