Google Sheets Function Guide

Google Sheets REGEXEXTRACT: Pull Emails, Domains & IDs From Messy Text

Use =REGEXEXTRACT(text, regular_expression) to pull structured codes, email domains, or numbers out of inconsistent notes and URLs without fragile nested LEFT/MID formulas.

1. Basic Syntax & How Capture Groups Work

The syntax for REGEXEXTRACT is:

=REGEXEXTRACT(text, "regular_expression")

2. Worked Examples: Common Extraction Patterns

Here are five copy-ready REGEXEXTRACT formulas tested on messy operational exports:

Extraction Task Sample Input (Cell A2) Formula Output
Extract email domain priya@acmeretail.example =REGEXEXTRACT(A2, "@(.+)") acmeretail.example
Extract prefixed Order ID Payment received for INV-2026-104 (ACH) =REGEXEXTRACT(A2, "INV-\d{4}-\d+") INV-2026-104
Extract first number (as real number) Plan: 250 GB Storage =VALUE(REGEXEXTRACT(A2, "\d+")) 250
Extract text inside parentheses Northstar Logistics (NET-30) =REGEXEXTRACT(A2, "\(([^)]+)\)") NET-30
Extract domain from full URL https://knowunlimited.com/excel/query =REGEXEXTRACT(A2, "https?://([^/]+)") knowunlimited.com

Numeric tip: REGEXEXTRACT always returns a text string. Wrap it with VALUE(...) whenever you plan to sum or compare extracted numbers.

3. Combining REGEXEXTRACT With ARRAYFORMULA

To extract email domains down an entire column of contacts in A2:A from a single cell at the top of column B:

=ARRAYFORMULA(IF(A2:A="", "", IFERROR(REGEXEXTRACT(A2:A, "@(.+)"), "Invalid Email")))

Learn more about whole-column formulas in our Google Sheets ARRAYFORMULA Guide.

4. Common REGEXEXTRACT Errors & Quick Fixes

Related Guides & Tools: Explore Google Sheets QUERY Guide, Google Sheets IMPORTRANGE Guide, Google Sheets ARRAYFORMULA Guide, or download starter workbooks from the Templates Pack.

5. Extracting Domains, Order IDs & Numbers Safely

Use parentheses ( ) around the exact substring you want to return, and pair REGEXEXTRACT with IFERROR so rows that don't match a pattern return blank instead of #N/A:

=IFERROR(REGEXEXTRACT(A2, "@([A-Za-z0-9.-]+\.[A-Za-z]{2,})"), "")
A B
# Raw Email / String Extracted Domain
2 billing@northstarstudio.com northstarstudio.com
3 support@harborlogistics.in harborlogistics.in