Reputation: 131
I want to check domains with regex. My old code was:
/^([a-z0-9]+([-a-z0-9]*[a-z0-9]+)?.){0,}([a-z0-9]+([-a-z0-9]*[a-z0-9]+)?){1,63}(.[a-z0-9]{2,7})+$/i
It is okey but this code doesn't validate IDNs (internationalized domain names) such as öü.com or öü.öü
My domain format is:
Besides, I don't want:
Important note: user can add the domains;
Upvotes: 2
Views: 2169
Reputation: 99011
Idn's such as भारत.icom.museum
use Punycode encoding, as defined in RFC 3492, before submission for DNS resolution.
It seems that you're using php, based on that, you should use the idn_to_ascii()
function to convert the idn's, ex:
echo idn_to_ascii("भारत.icom.museum");
//xn--h2brj9c.icom.museum
Upvotes: 2