Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^(?:[\w\d\.-_])+@(?=.{4,64}$)(?:[\w\d]+[-]?[\w\d]+\.|[\w\d]\.)+(?:\w{2,})$
/

Description

Usernames with dots, dashes and underscores. Hostnames limited to 64 chars, dash disallowed at first char of domain segment, only one consecutive dash or dot, one-char domains possible, multi-subdomains, long TLDs.

Submitted by Forseti - 9 years ago