DevKits

Validation

Match an email address

Flags: gi

Validate or extract email addresses like user@example.com from text.

Pattern

Regular expression

[\w.+-]+@[\w-]+\.[\w.-]+

How it works

This pragmatic pattern matches the vast majority of real-world email addresses. The local part allows word characters plus `.`, `+`, and `-`. The domain part allows word characters and `-`, followed by at least one dot and TLD characters.

Matches

  • user@example.com
  • alice.smith+news@sub.example.co.uk
  • u_1@a.io

Non-matches

  • plainaddress
  • @no-local.com
  • no-at-sign.com

Common gotchas

The full RFC 5322 email grammar is astonishingly complex — no reasonable regex captures it perfectly. For real validation, use a library (or send a confirmation email). This pattern is fine for extraction and casual validation.

Language snippets

JavaScript

const re = /[\w.+-]+@[\w-]+\.[\w.-]+/gi;
"contact user@example.com".match(re); // ["user@example.com"]

Python

import re
re.findall(r"[\w.+-]+@[\w-]+\.[\w.-]+", "contact user@example.com")

Go

import "regexp"

re := regexp.MustCompile(`[\w.+-]+@[\w-]+\.[\w.-]+`)
re.FindAllString("contact user@example.com", -1)

Java

import java.util.regex.*;

Matcher m = Pattern.compile("[\\w.+-]+@[\\w-]+\\.[\\w.-]+").matcher(text);
while (m.find()) System.out.println(m.group());

Related patterns

Try any pattern live in the Regex Tester