Regular Expressions 101

Community Patterns

valid email matching

1

Regular Expression
PCRE (PHP <7.3)

/
(?(DEFINE) (?<plain>[a-zA-Z0-9#!$%&'*+-\/=?^_`{}|~]+) (?<quote>"(?:\\"|[^"])*") (?<forbidden>(?<![.+])) (?<local_part>(?&quote)(?&forbidden)|^[^\.](?&plain)) (?<domain>[a-zA-Z0-9-.]+\.[a-zA-Z]{2,63}) (?<mail>(?&local_part)@(?&domain)) ) ^(?&mail)+$#.. will not handled
/
mx

Description

Pattern matches mails in a single line with right syntax. Exceptions double dots in mail (..) will not handled.

Submitted by Martin - 9 years ago