📚 General & Other

No Regex Fully Validates an Email Address

The grammar for a valid address permits quoted strings, comments and nested structures. The RFC-complete regular expression is thousands of characters long and still does not tell you whether the…

The grammar for a valid address permits quoted strings, comments and nested structures. The RFC-complete regular expression is thousands of characters long and still does not tell you whether the address exists.

Extraction and validation are different jobs

For pulling addresses out of prose, a pragmatic pattern — a run of permitted characters, an @, a domain with at least one dot — is correct and sufficient. Trying to make the extraction pattern also enforce full validity makes it worse at both.

Common false positives

Twitter handles, version strings and file paths can all resemble addresses in loose patterns. Trailing punctuation attaches to the match, and a sentence ending immediately after an address leaves a period on the end of the domain.

The only real validation is delivery

Syntax checks confirm the address is well formed. They cannot confirm the mailbox exists. Where deliverability matters, use a verification service, and treat the syntax check purely as a cheap first filter.

Try it: Extract Email Addresses from Text on SeoWolf's Notepad.