T
ToolPrime

Regex for Email Address

Validates email addresses following the standard format: local-part@domain.tld.

Pattern

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

Live Tester

Enter a string to test

Examples

user@example.com
john.doe+tag@company.co.uk
info@test.org
@example.com
user@
user@.com

Pattern Breakdown

^[a-zA-Z0-9._%+-]+ — starts with one or more alphanumeric characters or ._%+-

@ — literal @ symbol

[a-zA-Z0-9.-]+ — domain name with alphanumeric characters, dots, or hyphens

\.[a-zA-Z]{2,}$ — dot followed by a TLD of at least 2 letters

Code Snippets

Javascript

const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/i;
regex.test("user@example.com"); // true

Python

import re
pattern = r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
bool(re.match(pattern, "user@example.com", re.IGNORECASE))  # True

Php

$pattern = '/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/i';
preg_match($pattern, "user@example.com"); // 1

Related Patterns