Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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:

  ^nano\w+\.com$


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$


Unless the service was in the habit of selling impossible domain names, it shouldn't matter ;)

I intentionally left out the hyphen because it isn't a very desirable character.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: