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
Match a URL
https?:\/\/[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#\[\]@!$&'()*+,;=]*
Match a domain name
(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}
Match an IPv4 address
(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)
Match an IPv6 address
(?:[A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}|::1|::
Match a UUID (v4)
[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}
Match a US phone number
(?:\+?1[-. ]?)?\(?[2-9][0-9]{2}\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}