SoftwareTestPilot
Manual TestingPublished: 6 min read

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.

Avinash Kamble
Founder & QA Engineer at SoftwareTestPilot
Reviewed by Priyanka G.
Share:XLinkedInWhatsApp

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.com

Playwright 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?
Yes — as a UX hint. Server-side, always re-validate with a regex plus MX check.
2.Do I need to accept unicode local parts?
For international apps yes. Use the 'u' flag and \p{L} where supported.
3.What about plus-addressing (foo+tag@)?
Support it. Users rely on it for filtering; blocking it is an accessibility fail.
4.Is regex validation enough?
No — but it's the first cheap gate. Follow with delivery confirmation.
Keep going

Practice these questions

Run a live QA mock interview tailored to this topic and get per-skill scoring in minutes.

Found this useful?
Share:XLinkedInWhatsApp

Was this article helpful?

Cluster · Manual Testing

More from Manual Testing Basics

Test types, defect lifecycle, exploratory testing.

Pillar guide · 28 articles
More in this cluster
From the Manual Testing pillar

Keep building your QA edge

Continue reading

Join the QA Community

Connect with fellow testers, share job leads, and get career advice.

Premium QA Resources

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
4.9/5 rating
Explore All Products

⭐⭐⭐⭐⭐ Trusted by 1,000+ Software Test Pilots • Instant Access