Regular Expressions 101

Community Patterns

Community Library Entry

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 - a year ago