We’re improving Formula Genius. We’re redesigning the app and fixing issues along the way. Sorry for any disruption, and thank you for your patience.
Regex intermediate

Regex to Extract Email Addresses From Text

A common regex pattern for finding email addresses in unstructured text. Handles common formats and edge cases.

Formula Genius can generate a draft from a plain-English prompt. Supported formulas can be checked with sample cases; review the coverage on the result.

The formula

Prompt

"Extract all email addresses from a block of text"

Regex
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

This pattern matches the standard email format: local part (letters, numbers, dots, special chars) + @ symbol + domain (letters, numbers, dots) + TLD (2+ letters).

Step-by-step breakdown

  1. [a-zA-Z0-9._%+-]+ — local part: letters, numbers, dots, underscores, percent, plus, hyphen
  2. @ — literal @ symbol
  3. [a-zA-Z0-9.-]+ — domain: letters, numbers, dots, hyphens
  4. \\. — literal dot before the TLD
  5. [a-zA-Z]{2,} — TLD: at least 2 letters (com, org, io, etc.)

Edge cases & warnings

  • Doesn't match emails with IP address domains (user@[192.168.1.1])
  • Matches most common formats but not all RFC 5322 valid addresses
  • Quoted local parts ("john doe"@example.com) are not matched
  • International domain names (IDN) with non-ASCII characters need a broader pattern

Examples

Prompt

"Contact us at hello@example.com or support@test.co.uk"

Regex
hello@example.com, support@test.co.uk
Prompt

"Invalid: @nodomain.com or user@ or user@.com"

Regex
None matched (all invalid)

Frequently asked questions

Is this regex 100% RFC compliant?

No regex perfectly validates all RFC 5322 email addresses. This pattern handles 99%+ of real-world emails. For strict validation, use a dedicated email validation library.

How do I use this in Google Sheets?

Use =REGEXEXTRACT(A1, "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}") to extract the first email from cell A1.

Can't find what you need?

Describe a formula in plain English. Formula Genius drafts and explains it, and can check supported formulas on sample cases.