Regular Expressions 101

Community Patterns

IDN Domains and Subdomains

2

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?:[^:\/?#]+:)?(?:(?:\/\/)?(?:[^\s\/?#]+\.)+[^\s\/?#]+(?:\/[^\s"#]*)?)$
/
gm

Description

IDN Domains & Normal Domains This regex is able to identify any type of domain or subdomain whether it is IDN or normal, this includes domains in emojis, non-Latin characters, etc.

Submitted by NCK - 9 months ago