Email Validation Regex (JavaScript & Python)
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$Quick answer
This regex validates standard email addresses. It ensures there is text before and after the @ symbol, and requires a valid domain extension (like .com or .org).
🛠️ Fix it right here with AI Regex Generator
Need to modify this pattern or generate a new one? Edit the regex below and let our AI help.
Live Regex Tester
Type a string below to see if it matches this pattern.
How it works
The pattern breaks down into three parts: ^[a-zA-Z0-9._%+-]+ matches the username (allowing letters, numbers, dots, etc.), @[a-zA-Z0-9.-]+ matches the domain name, and \.[a-zA-Z]{2,}$ ensures a valid TLD (Top Level Domain) of at least 2 letters.
Code Examples
✅ Correct Usage
// JavaScript
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
console.log(emailRegex.test("test@example.com")); // true
# Python
import re
pattern = r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
print(bool(re.match(pattern, "test@example.com"))) # True❌ What NOT to do
// BAD: This allows invalid emails like "test@.com" or "test@com" const badRegex = /.+@.+/;
Frequently asked questions
Is this regex 100% accurate for all emails?
No regex is 100% perfect for every edge case of RFC 5322. However, this pattern covers 99.9% of real-world email addresses and is used by most websites.
Why not just use HTML5 type='email'?
HTML5 validation is great for frontend, but you STILL need regex on the backend (Python/PHP/Node) to prevent malicious bypasses.
Related Search Terms
Related Regex Patterns
Need a custom regex pattern?
Use the free to describe what you need in plain English.
Want an AI with memory for your project?
MonsterX AI remembers your codebase across chats.