Domain Name Regular Expression

A Regular Expression that matches most domains including subdomains and IDN domain names.

/^((?!-))(xn--)?[a-z0-9][a-z0-9-_]{0,61}[a-z0-9]{0,1}\.(xn--)?([a-z0-9\-]{1,61}|[a-z0-9-]{1,30}\.[a-z]{2,})$/

Domain Examples:

  • xn-fsqu00a.xn-0zwm56d
  • google.com.cn
  • stackoverflow.co.uk

See Also:

Regex Is Copied!