Thank you for pointing right direction in domain name validation solutions in other answers. Domain names could be validated in various ways.
If you need to validate IDN domain in it's human readable form, regex \p{L}
will help. This allows to match any character in any language.
Note that last part might contain hyphens too! As punycode encoded Chineese names might have unicode characters in tld.
I've came to solution which will match for example:
Regex is:
^[0-9\p{L}][0-9\p{L}-\.]{1,61}[0-9\p{L}]\.[0-9\p{L}][\p{L}-]*[0-9\p{L}]+$
NOTE: This regexp is quite permissive, as is current domain names allowed character set.
UPDATE: Even more simplified, as a-aA-Z\p{L}
is same as just \p{L}
NOTE2: The only problem is that it will match domains with double dots in it... , like maselk..owski.pl
. If anyone know how to fix this please improve.