Simple Email Address
beginnerBasic email validation matching user@domain.tld format.
Pattern
/[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}/giTry It
Explanation
Matches a basic email address: one or more word characters, dots, plus signs, or hyphens before the @, followed by a domain name with at least one dot and a TLD of 2+ letters.
When to Use
Use this pattern for basic client-side email format validation in forms. It catches obvious formatting errors like missing @ signs or missing domains. For strict RFC 5322 compliance, use the RFC 5322 pattern instead. Note: regex alone cannot confirm an email address exists — always send a verification email for production use.
Step-by-Step Breakdown
| Token | Explanation |
|---|---|
[\w.+-]+ | Match one or more word characters (a-z, 0-9, _), dots, plus signs, or hyphens — the local part before the @ |
@ | Match the literal @ symbol separating the local part from the domain |
[\w-]+ | Match one or more word characters or hyphens — the domain name (e.g., 'example' or 'my-company') |
\. | Match a literal dot (escaped with backslash) separating the domain from the TLD |
[a-zA-Z]{2,} | Match two or more letters — the top-level domain (e.g., com, org, uk) |
Common Mistakes
Using an unescaped dot before the TLD, e.g., [\w-]+.[a-zA-Z]{2,}
Fix: [\w-]+\.[a-zA-Z]{2,}Without the backslash, the dot matches any character, causing false positives like user@domain_com.
Restricting TLD length with {2,3} or {2,4}
Fix: [a-zA-Z]{2,}Newer TLDs like .technology, .museum, and .photography are longer than 4 characters. Use {2,} to allow any valid TLD length.
Omitting + from the local part character class, e.g., [\w.]+@...
Fix: [\w.+-]+@...Plus addressing (user+tag@example.com) is widely used for email filtering and subaddressing. Excluding + rejects these valid addresses.
Test Strings
Matching
- user@example.com
- john.doe+tag@company.org
- test-123@sub.domain.co.uk
Non-matching
- @example.com
- user@
- user@.com
- plaintext
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Limited support (ASCII-only word boundaries) |
| RUBY | Full support |
| CSHARP | Full support |
Code Snippets
const regex = /[\w.+-]+@[\w-]+\.[a-zA-Z]{2,}/gi;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);Common Variations
Case-sensitive TLD
[\w.+-]+@[\w-]+\.[a-z]{2,}Only matches lowercase TLDs
Related Patterns
Learn the Concepts
This pattern uses concepts covered in these lessons: