What I'm really after is a URL I can go to that gives me a list of tld's in
a form I can use in code...

Ie:   http://www.listoftlds.com/csv

Gives me:

com,uk,net,org etc...

Don't worry.  The reason I wanted it is for a regex to check if a domain is
valid (or at the very least follows the rfc's).

Here it is:

([a-z0-9]([-]|[a-z0-9])*[a-z0-9][.])+(.ac|.ad|.ae|.af|.ag|.ai|.al|.am|.an|.a
o|.aq|.ar|.ar|.as|.at|.au|.aw|.az|.ba|.bb|.bd|.be|.bf|.bg|.bh|.bi|.biz|.bj|.
bm|.bn|.bo|.br|.bs|.bt|.bv|.bw|.by|.bz|.ca|.cc|.cd|.cf|.cg|.ch|.ci|.ck|.cl|.
cm|.cn|.co|.coop|.com|.cr|.cu|.cv|.cy|.cx|.cz|.de|.dj|.dm|.do|.dk|.dz|.ec|.e
du|.ee|.eg|.eh|.er|.es|.et|.eu|.fi|.fk|.fm|.fo|.fr|.fx|.ga|.gd|.ge|.gf|.gg|.
gh|.gi|.gl|.gm|.gn|.gov|.gp|.gq|.gr|.gs|.gt|.gu|.gy|.gw|.hm|.hn|.hk|.hr|.ht|
.hu|.id|.ie|.il|.im|.in|.info|.int|.io|.iq|.ir|.is|.it|.je|.jm|.jo|.jp|.ke|.
kg|.ki|.kid|.km|.kn|.kp|.kr|.ky|.kw|.kz|.la|.lb|.lc|.li|.lk|.lr|.ls|.lt|.lu|
.lv|.ly|.ma|.mc|.md|.mh|.mg|.mil|.mk|.ml|.mm|.mn|.mo|.mp|.mq|.mr|.ms|.mt|.mu
|.museum|.mv|.mw|.mx|.my|.mz|.na|.name|.nc|.ne|.net|.nf|.ng|.ni|.nl|.no|.np|
.nr|.nu|.nz|.om|.org|.pa|.pe|.pf|.pg|.ph|.pk|.pl|.pm|.pn|.pr|.pro|.pt|.pw|.p
y|.qa|.re|.ro|.ru|.rw|.sa|.sb|.sc|.sd|.se|.sg|.sh|.si|.sj|.sk|.sl|.sm|.sn|.s
o|.sr|.st|.su|.sv|.sy|.sz|.tc|.td|.tf|.tg|.th|.tj|.tk|.tm|.tn|.to|.tp|.tr|.t
t|.tv|.tw|.ua|.ug|.us|.uk|.um|.uy|.uz|.va|.vc|.ve|.vg|.vi|.vn|.vu|.wf|.ws|.y
e|.yt|.yu|.za|.zm|.zw|.ad|.ae|.al|.am|.at|.az|.ba|.be|.bf|.bg|.bh|.bj|.by|.c
f|.ch|.ci|.cm|.cv|.cy|.cz|.de|.dj|.dk|.dz|.ee|.eg|.er|.es|.eu|.fi|.fo|.fr|.g
a|.gb|.ge|.gg|.gh|.gi|.gn|.gq|.gr|.gw|.hr|.hu|.ie|.il|.im|.io|.iq|.ir|.is|.i
t|.je|.jo|.ke|.kg|.kz|.lb|.li|.lr|.lu|.lv|.ma|.mc|.md|.mk|.ml|.mt|.ne|.ng|.n
l|.no|.om|.pl|.pt|.qa|.ro|.ru|.sa|.se|.si|.sj|.sk|.sl|.sm|.sn|.su|.sy|.td|.t
j|.tm|.tn|.tr|.ua|.ug|.uk|.uz|.va|.ye|.yu)

Exciting isn't it?

Basically if you put [a-zA-Z0-9_and whatever else works in an email
address]@ and then the above, you can test if an email
Address has a valid domain.

NOTE: The regexes are case sensitive and I didn't put the a-zA-Z in because
you can just do a case insensitive match with the above regex

Seems pointless to me!  To make it simpler, just use this (although the tld
won't be checked):

([a-z0-9]([-]|[a-z0-9])*[a-z0-9][.])+([a-z0-9]([-]|[a-z0-9])*[a-z0-9])

To put in the most common tlds (you can put more in), you could easily do
this:

([a-z0-9]([-]|[a-z0-9])*[a-z0-9][.])+(([a-z0-9]([-]|[a-z0-9])*[a-z0-9])|com|
co[.]uk|net|org|com[.]uk)

Which is actually syntactically valid according to the RFC!  It basically
says:

Domains MUST start and end in a letter or digit
Between the start and end letter/digit, the domain can contain 0 or more
letters, digits or hyphens
Domains are delimited by dots (or periods if you're american)
There can be any number of subdomains up to 63 (min) or 255 (recommended)
believe it or not!

Did you know that a--b.com is a valid domain name?  Didn't realise you could
have double hyphens in a domain name (although why would you?)

These regexes are untested, but you should be able to figure it out!

HTH

Paul

PS The main regex is this:

[a-z0-9]([-]|[a-z0-9])

And [.] as a delimiter and not much more

Everything stems from this one regex

-------------------------------------------
Paul Johnston
PJ Net Solutions Ltd
http://www.pjnetsolutions.com
[EMAIL PROTECTED]
+44 (0)7866 573013




--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to