commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Jackson <>
Subject Re: validator: howto validate domain names
Date Thu, 05 Jun 2003 15:16:37 GMT
Hey Andy,

Regexp for domain names.....


works to something like.....
( alphanum word ) + ('.' + alphanum word)(optional/many occurrences
possible) + ('.' + alphanum word) + line end.

It is actually part of an email validation rule I lifted from a user
comment at  (thanks to the original poster. I believe it can
still be found at )

if you are picky you can swap something like this in for the last part
of the expression to validate known TLDs...  
( but you will have to remember to maintain it )
(com|net|org|edu|mil|gov|info|tv|biz|de|sk|ca|uk|....and so on......)

Here is the full email validation rule I use....

org.apache.regexp.RE emailPattern = new

I use this expression heavily in various forms using php and perl in
production.  I have NOT TESTED this in java on a production site yet.

On Thu, 2003-06-05 at 09:46, Andy Pahne wrote:
> Hello,
> I wonder how to validate domain names like "" or
> "".
> By the way: I am looking only for syntax validation. I'm not interested in
> DNS lookups to check, if the given domain exists.
> I have no idea how to create a regular expression that handles domains and
> subdomains (any level).
> Thanks,
> Andy
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message