Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^((([a-z0-9][a-z0-9\-]*[a-z0-9])|[a-z0-9]+)\.)*([a-z]+|xn\-\-[a-z0-9]+)\.?$
/

Description

  • Allow only two or more labels.
  • Fix deprecated FQDN regexp not passing on test "dicas-l.com.br"
Submitted by Rafael Justo and Mauro Trajber - 9 years ago