Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
(([A-Za-z0-9]+\w*[\.\-]?){1,}+\w*@([A-Za-z0-9]+\.){1,2}[A-z]{2,3})
/
g

Description

Validates most email addresses. Using the range [A-Za-z0-9] at the beginning instead of \w means an address cannot begin with an underscore. This range is also used to exclude underscores from the domain (part after @).

Submitted by Owen Howard - 10 years ago