Re:Ask HN: Domain name searching
by tdavis on Saturday April 04, 2009 @02:49AM
(#546162)
Not to be "that guy", but that isn't really a regular expression unless you are searching for nan.com, nano.com, nanoo.com, etc. I think you want:
[ Parent
| on HN ]
Not to be "that guy", but the word character class includes underscores, which is not valid in a domain name. What you would really want is
^nano[a-z0-9-]+[a-z0-9]+.com$
The first character class includes the hyphen, the second does not, because you can't start or end a domain with a hyphen.That regexp would allow a hyphen as the first character. How about this (still assuming .com is the only permitted TLD):
[a-z0-9][a-z0-9-]*[a-z0-9].com$
on further thought, it doesn't matter than it will match underscores, because the list of domains shouldn't have any underscores in them, but you would still want to look for underscores (maybe)
^nano[\w-]+\w+.com$