DevTools Hub

Search tools

Search for a developer tool

Regex for Email

Part of the Regex Toolkit
Pattern
^[\w.+-]+@[\w-]+\.[\w.-]+$

anchored to validate a whole string; drop ^ and $ to find emails inside larger text

Explanation

This pattern checks three things in order: a local part before the @ made of letters, digits, and the punctuation actually common in email addresses (. + - and underscore); a literal @; and a domain made of the same word characters, requiring at least one dot before the end so a bare word like localhost doesn't pass as a domain.

No regex — this one included — actually validates that an address is real or deliverable, and a pattern that tries to match the full RFC 5322 grammar exactly is famously long and still ends up debated. This one is a practical middle ground, and like any practical middle ground it has known edges: it accepts a domain with a doubled dot (user@example..com, not a real domain) and rejects a local part containing an apostrophe (o'brien@example.com, technically legal per RFC 5321 but rare enough in practice that most validators reject it too). If an address genuinely needs to work, the only real test is sending it a confirmation email — a regex just catches typos before that step.

This is the same pattern used as the "Email" preset in Regex Builder, kept anchored here (^/$) for validating that an entire string is one email address. Drop the anchors to find email addresses embedded inside a larger block of text instead.

Valid examples

  • jane.doe@example.com

    A standard address — letters, a dot, and a two-part domain.

  • jane+newsletter@example.com

    Plus-addressing in the local part, common for filtering and disposable aliases.

  • user@sub.example.co.uk

    A subdomain plus a multi-part TLD — the domain side allows any number of dot-separated segments.

Invalid examples

  • user@example

    No dot in the domain — rejected so a bare word like "localhost" can't pass as a domain.

  • user name@example.com

    A space in the local part — not a valid email character here.

  • @example.com

    Missing local part entirely — there's nothing before the @.

Try it now