Email Regex Validation in Test Automation — Do It Right
How to validate email input in Selenium, Playwright, and Cypress with a regex that balances accuracy and pragmatism. Includes boundary test cases.
2026-07-17 · By Avinash Kamble, reviewed by Priyanka G.
Every signup form has an email field. Testing it well means picking a pragmatic regex and covering the boundary cases — not writing a 6,000-character RFC 5322 monster.
The pragmatic regex
^[\w.+-]+@[\w-]+\.[\w.-]+$Covers 99% of real-world addresses; rejects the obvious garbage. Test it in the Regex Tester for QA before shipping.
Boundary test cases
VALID
a@b.co
first.last+tag@example.com
user_name@sub.example.co.uk
INVALID
plaintext
@nodomain.com
name@.com
name@domain
name@@domain.com
name domain@example.comPlaywright example
const invalidEmails = ['plain', '@no.com', 'a@b'];
for (const email of invalidEmails) {
await page.getByLabel('Email').fill(email);
await page.getByRole('button', { name: 'Sign up' }).click();
await expect(page.getByText('Enter a valid email')).toBeVisible();
}Don't stop at regex
A well-formed email doesn't mean a deliverable email. Also verify: MX record checks, disposable-domain blocking, and confirmation email delivery. Regex is the cheap first gate.
Frequently asked questions
1.Should I use HTML5 type='email' as validation?
2.Do I need to accept unicode local parts?
3.What about plus-addressing (foo+tag@)?
4.Is regex validation enough?
Practice these questions
Run a live QA mock interview tailored to this topic and get per-skill scoring in minutes.
Was this article helpful?
More from Manual Testing Basics
Test types, defect lifecycle, exploratory testing.
- Career & Interview PrepThe Honest Truth About Manual Testing Salaries in 2026 (Real Data)
- Manual TestingTest Pyramid Explained: A Practical Guide for QA (2026)
- Manual TestingHow to Write Test Cases for a Login Page (with Examples)
Keep building your QA edge
Pillar guides- Regex Tester for QAregex tester for QA engineersLive regex tester with 25+ QA-focused prebuilt patterns and code export for Java, Python, JS, .NET, Go, Playwright, and Rest Assured.
- AI Mock InterviewAI Mock InterviewLive AI-powered mock interviews with rubric feedback.
- ATS Resume Reviewcheck your ATS score instantlyFree AI ATS scoring with rewrite suggestions.
Continue reading
Join the QA Community
Connect with fellow testers, share job leads, and get career advice.
Stop Reinventing the Wheel. Upgrade Your QA Arsenal.
Take your testing skills from beginner to Lead Engineer. Supercharge your daily workflow with our premium digital resources.
- Ready-to-use testing strategy templates
- Advanced API & UI automation guides
- ⏱️ Save 10+ hours a week on test planning


