Regular Expressions 101

Community Patterns

Pretty Decent email validator

0

Regular Expression
PCRE (PHP <7.3)

/
(?|^(?=(\".*?\"|[^\r\n\"]+)@)(?!.*?@(\..*?\.|\..*?|.*?\.|.{256,})$)(?=(.*?@([a-z0-9\-]{1,63}\.)+|^)[a-z0-9\-\.]{1,64}$)((?!\.|^.*?\.{2,}.*?@)[a-z0-9_\-\.\"!#$%&'*+ \/=?^`{|}~]{1,64}@(?<!\.@)(?!\-|.*?(\.\.|@).*?)([^\.]{1,63}|([a-z0-9\-\.]{1,63})+)(?<!\-)\.[a-z\d\-]{2,24})$)
/
gim

Description

This one gets close to handling most valid email address examples using the specification from RFC 282 ISO standard

__ It doesn'T handle everything but manages fairly well...

Submitted by anonymous - 6 years ago