Community Patterns

Community Library Entry

0

Regular Expression
Created·2017-05-31 20:05
Flavor·PCRE (Legacy)

/
^ (?(DEFINE)(?<part>(?:xn--)?[a-z\d](?:[a-z\d-]*[a-z\d])?)) (?(DEFINE)(?<subpart>(?:xn--)?[a-z\d_](?:[a-z\d_-]*[a-z\d])?)) (?:(?&subpart)\.)* (?&part) (?:\.[a-z]+|\.xn--[a-z\d]+){1,2} $
/
xigm
Open regex in editor

Description

This regex provides a basic syntax sanity check on an International Domain Name (IDN) which has been converted to ASCII (e.g. via the PHP function idn_to_ascii() from the php-intl package.

Does not guarantee the actual domain name is valid (let alone registered), but only a very basic syntax check.

Submitted by Doqnach