Regex example for e-mail address validation
A regular expression for checking the shape of an e-mail address in website forms, plus notes on what validation can and cannot prove.
Every form that collects an e-mail address raises the same question: did the user actually type an address? The regular expression below checks whether the input matches the shape of an e-mail address.
It has three parts: the local part before the @ sign, the domain, and the extension. Letters, digits, dots, plus signs and hyphens are accepted in the first two; the extension must be 2–4 letters long.
Keep in mind that a format check does not prove the address exists — only that it is written correctly. The only way to be sure is to send a verification e-mail. This expression is the first filter that stops pointless requests reaching your server.
[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\.[a-zA-Z]{2,4}
Short guide
When to use it
An e-mail regex is useful as a first check in signup forms, contact forms, quote requests and admin user screens. It checks the shape of the address; it does not prove that the mailbox exists.
What to watch
- Show quick feedback on the frontend, but repeat the validation on the server.
- Avoid overly strict expressions that reject valid but uncommon addresses.
- If ownership matters, send a confirmation link or one-time code.
Common mistake
Relying only on regex for e-mail validation is misleading. Regex checks format; deliverability, domain status and ownership are separate issues.
Before using this in a project
Regex examples are useful shortcuts, but real projects should also consider the data source, line endings, browser/server differences and user input mistakes. In web forms, admin panels and custom software, validation should not live only on the frontend; the server side should check it too.