~/devtools / regex / email
tool::regex-guide

regex email

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

Email Address Validation

ad · 728×90
Regex Pattern
/^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/i
Flags:i
Pattern Breakdown
^Start of string
[a-zA-Z0-9._%+\-]+Local part: letters, digits, dots, special chars
@Literal @ symbol (required)
[a-zA-Z0-9.\-]+Domain name: letters, digits, dots, hyphens
\.Literal dot before TLD
[a-zA-Z]{2,}TLD: at least 2 letters (com, org, io…)
$End of string
Matching Examples
user@example.com
name.surname+tag@sub.domain.org
dev@company.io
Non-Matching Examples
user@
@domain.com
no-at-sign.com
user @example.com

A practical email validation pattern based on RFC 5322. It covers the local part (before @) and domain part (after @) for the most common email formats. Note: internationalized domains (IDN) and IP-literal domains require additional handling.

Language Usage

JavaScriptUse RegExp object or literal syntax
const pattern = /^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/i;

// Test a string
console.log(pattern.test("user@example.com")); // true
console.log(pattern.test("user@")); // false

// Match and extract
const result = "user@example.com".match(pattern);
PythonUse the re module
import re

pattern = r"^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$"
flags = re.IGNORECASE

# Test a string
if re.fullmatch(pattern, "user@example.com", flags):
    print("Valid")

# Find all matches in text
matches = re.findall(pattern, text, flags)
JavaUse java.util.regex package
import java.util.regex.*;

String pattern = "^[a-zA-Z0-9._%+\\-]+@[a-zA-Z0-9.\\-]+\\.[a-zA-Z]{2,}$";
Pattern p = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);

Matcher m = p.matcher("user@example.com");
boolean isValid = m.matches(); // true

// Find occurrences
Matcher finder = p.matcher(inputText);
while (finder.find()) {
    System.out.println(finder.group());
}

Common Use Cases

  • Validate email fields on sign-up forms
  • Check newsletter subscription email inputs
  • Verify email column format in databases
  • Clean email data in CSV or Excel files
  • Validate email fields in API request bodies

Related Patterns

phone/^\+?[\d\s\-\(\)]{7,15}$/url/^https?:\/\/[^\s\/$.?#].[^\s]*$/iip-address/^((25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\./date/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[/
ad · 300×250
Back to Regex Tester
// related tools
Cron Expression Generator
Build and parse cron expressions visually. Generate human-readable descriptions and preview next execution times.
jwt
JWT Decoder
Decode and inspect JWT tokens. View header, payload, and signature details.
Color Converter
Convert colors between HEX, RGB, HSL, and more. Pick colors visually.
ts
Timestamp Converter
Convert Unix timestamps to human-readable dates. Supports ms/s, UTC/local, and relative time.