Regular Expressions 101

Community Patterns

Validate and decompose email address (English alphabet compliant)

1

Regular Expression
PCRE (PHP <7.3)

/
^(?=[A-Z0-9][0-9a-z.%_'+@-]{2,253}$)(?'localpart'(?'mailbox'[0-9a-zA-Z.%_'-]{1,250})(?:\+(?'tag'[0-9a-zA-Z._'-]{1,250}))?)@(?'networkpart'(?:(?'fqdn'(?'domain'(?:[0-9a-zA-Z-]{1,63}\.){0,8}[0-9a-zA-Z-]{1,63})\.(?'tld'(?:[a-zA-Z]{2,16}|[xX][nN]--[a-zA-Z]{4,18}(?:-[a-zA-Z]{3})?)))|(?'hostname'[0-9a-zA-Z_'-]{1,250})))$
/
gmi

Description

If you understand the regexp, you can adjust it to your need.

Submitted by RonanKER - 7 years ago