Regular Expressions 101

Community Patterns

Regex for e-mail verification

1

Regular Expression
PCRE (PHP <7.3)

/
^(?:(?:(?:[!#-'*+\-\/0-9=?A-Z^-~]+|(?:\"(?:[\ \t!#-\[\]-~]|(?:\\[\t\ -~]))+\"))(?:\.(?:[!#-'*+\-\/0-9=?A-Z^-~]+|(?:\"(?:[\ \t!#-\[\]-~]|(?:\\[\t\ -~]))+\")))*))@(?:(?:[!#-'*+\-\/0-9=?^-~]+(?:\.[!#-'*+\-\/0-9=?^-~]+)*(?:\.[!#-'*+\-\/0-9=?^-~]{2,})))$
/

Description

This regex checks if an email address is valid. It doesn't allow domain parts in the format [255.255.255.255]. It requires at least a domain and tld. (me@local is not allowed) It does allow quoted strings in the local part. It doesn't allow comments. Neither in the local nor in the domain part. It does allow a untypical domain names like me@_foo-.bar*

Submitted by anonymous - 8 years ago