Learn how to validate email addresses using regex. Copy-paste ready pattern with examples and test cases.
/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g| Token | Meaning |
|---|---|
[a-zA-Z0-9._%+-]+ | One or more letters, digits, dots, underscores, percent signs, plus signs, or hyphens (local part) |
@ | Literal @ symbol |
[a-zA-Z0-9.-]+ | One or more letters, digits, dots, or hyphens (domain name) |
\. | Literal dot separator |
[a-zA-Z]{2,} | Two or more letters (TLD like .com, .org) |
user@example.comMatchjohn.doe+work@company.co.ukMatchname_123@test.orgMatchinvalid@No match@nodomain.comNo matchname@domain.cNo matchconst emailRegex = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
const text = "Contact us at hello@example.com or support@test.co.uk";
const matches = text.match(emailRegex);
console.log(matches); // ["hello@example.com", "support@test.co.uk"]import re
email_regex = r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}'
text = "Contact us at hello@example.com or support@test.co.uk"
matches = re.findall(email_regex, text)
print(matches) # ['hello@example.com', 'support@test.co.uk']Want to test this pattern with your own data?
Try this pattern in Regex Tester →