Shaun Inman: Validating Domain Names. ⇒
8 May 2006, lunch time
That is a damn long regex.
This is a post from my link log: If you click the title of this post you will be taken the web page I am discussing.
8 May 2006, lunch time
That is a damn long regex.
This is a post from my link log: If you click the title of this post you will be taken the web page I am discussing.
I’ve seen longer lol.
His pattern matching is kind of brute force though, with a lot of overlap, and there are lots of countries that don’t allow you to have a direct tld. Like .au, .uk, .tw etc.
And there’s no support for IDNA or punycode domains.
by Iluvitar on May 8 2006, 2:29 pm #
You should post a comment. Maybe he will fix all that. I’m impressed you took the time to review the expression. I looked at it and though, “Damn that’s a long Regex.” And that’s about that.
by ramanan on May 8 2006, 2:33 pm #
Nah. I just like to nitpick hahaha. And then secretly apply fixes I make and integrate them into my own projects muhuhuhuhuh
Actually, I have no use for validating domain names with a regexp. It’s kind of an acid exercise where you catch idiots who enter garbage or something, but can’t catch people that really want to spoof something. And then you’ve wasted all this processing power to run a regexp on the string and then realise you have to reparse it anyways to generate a real dns query to actually test its validity. Well formed means nothing since it might not even be a valid, registered domain.
by Iluvitar on May 8 2006, 2:50 pm #