Why There Is No Perfect Email Regex (and What to Use Instead)
Why does no perfect email validation regex exist? Because the standard that defines what an email address can look like, RFC 5322, allows forms that break every reasonable pattern. Quoted local parts, comments in parentheses, domain literals like user@[192.168.1.1]. A fully compliant regex exists, but it runs to thousands of characters of unreadable noise, and after all that work it still cannot tell you whether the address belongs to a real inbox. The perfect email regex is a trap, and the industry quietly stopped chasing it years ago.
The history here is worth knowing because it keeps repeating. Every few years someone publishes a new "definitive" email pattern, it makes the rounds, and then someone feeds it "very.unusual.@.unusual.com"@example.com, which is a valid address under the RFC, and the pattern falls over. The standard is bigger than the regex. It will always be bigger than the regex.
What the serious people actually do
Look at what the HTML5 specification does for <input type="email">. It defines its own simplified pattern, and the spec openly calls it a willful violation of RFC 5322. The browsers are not even trying to validate email addresses fully. They check the rough shape, something, an at sign, something, a dot, something, and leave the rest to the application.
That is the right instinct, and it is worth copying. Use a simple shape check to catch typos:
^[^\s@]+@[^\s@]+\.[^\s@]+$
It rejects not-an-email and user@ and accepts user+tag@example.museum. It will accept some strings that are not real addresses. That is fine, because no regex can do the job that comes next.
The only real validation
The only way to know an email address is valid is to send mail to it and get a click back. The verification email with a confirmation link does the real validation work. It confirms the address exists, the mailbox accepts mail, and the person who typed it can read it. A regex can do none of those things, not even in principle.
This is also where the strict-regex approach actively hurts. Every over-strict pattern rejects some real user's address: the plus-addressing user, the person on a new long TLD, the corporate address with a quoted local part. Each rejection is a lost signup from someone who did everything right. A signup form that rejects valid addresses is a bug, not a security feature.
Where I would draw the line
If I were writing the validation for a new form tomorrow, it would be three steps: the shape check above on the client, the same check on the server because client validation is decoration, and a verification email before the account can do anything that matters. Skip the 6,000-character pattern, skip the regex you found in a ten-year-old Stack Overflow answer that rejects plus signs, skip the library that promises RFC compliance. They solve the part of the problem that does not matter and break the part that does.
Generate the simple pattern and test it against your own edge cases here, then spend the saved time on the confirmation flow.
Frequently asked questions
Is there a perfect regex for email validation?
No. RFC 5322, the standard that defines email address syntax, permits forms like quoted strings, comments, and IP-literal domains that no practical regex covers. Fully compliant patterns exist but run to thousands of characters, are unreadable, and still cannot confirm an address actually works.
What email regex does the HTML5 spec use?
The HTML5 specification defines its own simplified pattern for input type=email, a deliberate "willful violation" of RFC 5322 that checks the general shape: something, an @, something, a dot, something. Browsers intentionally do not try to fully validate email addresses.
Why do most email regexes reject valid addresses?
Because they encode assumptions about what an email looks like: no plus signs, a short TLD, no quoted local parts. Real inboxes use plus addressing (user+tag@example.com), new long TLDs, and quoted strings, all of which common patterns reject.
What should I use instead of a strict email regex?
A simple shape check (text, @, text, dot, text) to catch typos, followed by a verification email with a confirmation link. Only a successful delivery and click proves the address is real and belongs to the person who typed it.
Related reading: Regex URL Validation Mistakes · Phone Number Regex vs libphonenumber · Password Strength: Regex vs zxcvbn · Regex Catastrophic Backtracking