Regular Expressions 101

Community Library Entry

-2

Regular Expression
PCRE (PHP <7.3)

/
^((?:[A-Za-z0-9#\-_~!$&'()*+,;=:]|[A-Za-z0-9#\-_~!$&'()*+,;=:][A-Za-z0-9#\-_~!$&'()*+,;=:\.]*[A-Za-z0-9#\-_~!$&'()*+,;=:])@(?:[A-Za-z0-9]\.|[A-Za-z0-9][A-Za-z0-9#\-]{0,61}[A-Za-z0-9]\.)+(?:[A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9#\-]{0,61}[A-Za-z0-9]))\.?$
/

Description

matches normal email addresses like example@gmail.com but also addresses with ip addresses like example@192.168.0.34 (not ipv6)

Submitted by Adrian Kühni - 9 years ago