Regexdrill

Level 3: Real-world validation Exercise 26 of 52 Pro

Simple email addresses

A regex exercise from Regexdrill. Solve it with a pattern box with live highlighting in your browser, checked against hidden test strings, and it is checked the moment you submit.

The task

The whole line must match. Use this simplified rule: a local part of letters, digits, dots, underscores, plus signs or hyphens; one @; one or more domain labels of letters, digits or hyphens separated by dots; and a final label of two or more letters.

What this exercise teaches

[\w.+-]+@[A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*\.[A-Za-z]{2,} follows the stated rule. Real email rules are much looser; this is a practical filter.

A hint if you get stuck

Build it in three parts: the local part, the @, then labels that each begin after a dot. The last label is letters only.

This exercise is part of Pro

Pro unlocks all 52 exercises, with worked solutions and progress saved to your account. The free exercises work without an account.

You create a free account first, so Pro is attached to it.

Monthly is charged today and then every month until you cancel, in one click from your account page. Lifetime is one payment with no renewals. Full refund within 14 days of paying.

Start with the free exercises

More exercises in Real-world validation