~/regex-tester

Match email addresses with regex

A practical regex for matching email addresses, plus the limits of regex validation, the RFC 5322 hairball, and a tested working pattern.

# pattern

/[\w.+-]+@[\w-]+\.[\w.-]+/gi

→ Open in regex tester (pre-filled)

# how it works

The local part allows letters, digits, dots, plus signs, and hyphens (covers Gmail "+aliases"). The domain part is letters/digits/hyphens, then a dot, then a TLD that allows multiple dots (".co.uk"). The /i flag makes it case-insensitive; /g finds every match.

# sample input

Ping [email protected] or [email protected] for the change-request. Cc [email protected] on Monday.

# pitfalls

# other patterns