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:
- IP Address (V6) With Port Regular Expression
- IP Address (V4) With Port Regular Expression
- Subnet Mask Regular Expression
- URL (With And Without Port Number) Regular Expressions
- Regular Expression To Match All URLs In Text
- Regex To Extract Domain Name From URL
- DNS Hostname Regular Expression