Back to Home

Regex Pattern to Match Email Addresses

CronOS Team
regexemailvalidationtutorialbeginners

Need to generate a regex pattern?

Use CronOS to generate any regex pattern you wish with natural language. Simply describe what you need, and we'll create the perfect regex pattern for you. It's completely free!

Generate Regex Pattern

Regex Pattern to Match Email Addresses

A simple explanation of the email regex pattern ^[\w\.-]+@[\w\.-]+\.\w+$ and how it works.

Pattern Breakdown

regex
^[\w\.-]+@[\w\.-]+\.\w+$

Components

ComponentDescriptionMatches
^Start anchorEnsures match from string start
[\w\.-]+Local partOne or more: word chars, dots, hyphens
@SeparatorLiteral @ symbol
[\w\.-]+Domain nameOne or more: word chars, dots, hyphens
\.TLD separatorLiteral dot (escaped)
\w+TLDOne or more word characters
$End anchorEnsures match to string end

Character Classes

  • \w - Word characters: [a-zA-Z0-9_]
  • \. - Literal dot (escaped, since . matches any char)
  • - - Literal hyphen
  • + - Quantifier: one or more occurrences

Examples

Valid:

  • user@example.com
  • john.doe@company.org
  • test_email@sub.domain.com
  • user-123@domain-name.net

Invalid:

  • user@domain (missing TLD)
  • @domain.com (missing local part)
  • user@.com (missing domain)
  • user name@domain.com (space not allowed)
  • user@domain..com (double dot)
  • user@domain.co.uk (multi-part TLD not supported)

Implementation

JavaScript

javascript
const emailRegex = /^[\w\.-]+@[\w\.-]+\.\w+$/;
emailRegex.test('user@example.com'); // true

Python

python
import re
email_regex = r'^[\w\.-]+@[\w\.-]+\.\w+$'
bool(re.match(email_regex, 'user@example.com'))  # True

Go

go
emailRegex := regexp.MustCompile(`^[\w\.-]+@[\w\.-]+\.\w+$`)
emailRegex.MatchString("user@example.com") // true

Limitations

  1. Multi-part TLDs: Doesn't match .co.uk, .com.au
  2. No length validation: RFC 5322 limit is 320 characters
  3. No quoted strings: Doesn't support "user name"@example.com
  4. No plus signs: Doesn't allow + in local part

When to Use

  • Client-side form validation
  • Basic format checking
  • Quick validation before API calls

For production, consider RFC 5322-compliant patterns or validation libraries, and always verify emails via confirmation messages.

Need to generate a regex pattern?

Use CronOS to generate any regex pattern you wish with natural language. Simply describe what you need, and we'll create the perfect regex pattern for you. It's completely free!

Generate Regex Pattern