Email Address Regex

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

Validate email addresses with this comprehensive regex pattern. Matches standard email formats including subdomains and new TLDs.

Test This Pattern →

Pattern Breakdown

Understanding the regex pattern ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$:

  • ^ - Start of string
  • $ - End of string
  • + - One or more
  • [...] - Character class
  • {n,m} - Quantifier (n to m times)

Examples

Input Result Explanation
user@example.com ✓ Match Standard email format
user.name+tag@example.co.uk ✓ Match Complex email with subdomain
invalid-email ✗ No Match Missing @ and domain
@example.com ✗ No Match Missing local part

Code Examples

JavaScript

JavaScript
const pattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
const text = "user@example.com";

// Test if string matches
if (pattern.test(text)) {
  console.log("Valid!");
}

// Extract matches
const matches = text.match(pattern);
console.log(matches);

Python

Python
import re

pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
text = "user@example.com"

# Test if string matches
if re.match(pattern, text):
    print("Valid!")

# Find all matches
matches = re.findall(pattern, text)
print(matches)

PHP

PHP
<?php
$pattern = '/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/';
$text = "user@example.com";

// Test if string matches
if (preg_match($pattern, $text)) {
    echo "Valid!";
}

// Find all matches
preg_match_all($pattern, $text, $matches);
print_r($matches);
?>

Java

Java
import java.util.regex.*;

String pattern = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
String text = "user@example.com";

Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(text);

if (m.matches()) {
    System.out.println("Valid!");
}

Use Cases

Common applications: Form validation, user registration, contact forms

Frequently Asked Questions

What is the regex pattern for email address regex?
The regex pattern is: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$. Validate email addresses with this comprehensive regex pattern. Matches standard email formats including subdomains and new TLDs.
How do I use the email address regex pattern in JavaScript?
In JavaScript: const regex = new RegExp('^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$'); or const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
Does this pattern work in Python?
Yes, use: import re; pattern = re.compile(r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$') in Python. Most regex patterns are cross-language compatible.
What are common use cases for email address regex?
Form validation, user registration, contact forms

Related Regex Patterns

More Regex Tools

GetDevUtils offers a suite of developer tools including: