regex email pattern — validate and extract email addresses

# Practical email validation pattern
/^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/

// JavaScript
function isValidEmail(email) {
  return /^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/.test(email);
}

# Python
import re
def is_valid_email(email):
    return bool(re.match(r'^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$', email))

Validate user-entered email addresses or extract emails from text.

Extract all emails from text

// JavaScript
const text = 'Contact alice@example.com or bob@test.org for help';
text.match(/[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}/g)
// ['alice@example.com', 'bob@test.org']

# Python
import re
re.findall(r'[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}', text)

Pattern breakdown

^                   start of string
[a-zA-Z0-9._%+\-]+  local part (before @)
@                   literal @
[a-zA-Z0-9.\-]+     domain name
\.                  literal dot
[a-zA-Z]{2,}        TLD (2+ letters)
$                   end of string

Note: perfect email validation is impossible with regex

For production use, send a verification email rather than relying solely on regex. The full RFC 5322 spec allows characters that most simple patterns reject.

// HTML5 built-in validation (recommended for forms)
<input type="email" required />