FormulaFix · Plain-English guides to Excel and Google Sheets formulas

How to Use REGEXEXTRACT in Google Sheets: 6 Examples With Results

REGEXEXTRACT pulls the part of a text that matches a pattern (a regular expression). It exists in Google Sheets only. Excel has no function with this name.

Syntax

=REGEXEXTRACT(text, regular_expression)

Write regex symbols with a single backslash: \d for a digit, \. for a literal dot. You do not double the backslash in Google Sheets.

Pattern cheat sheet

Symbol Meaning Example pattern Matches
\d One digit \d{4} 2026
\w Letter, digit or underscore \w+ file_2
\s Whitespace \s+ spaces
. Any character a.c abc, a1c
+ One or more \d+ 7, 2026
? Optional colou?r color, colour
^ and $ Start and end of text ^Mr Mr at the start
[ ] A set of characters [A-Z]{2} AB
( ) Capture group (\d+) the part returned

Example 1: Extract an email address

A (text)
Contact: john.doe@example.com, thanks
=REGEXEXTRACT(A2, "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}")

Result: john.doe@example.com

Example 2: Extract a date in YYYY-MM-DD format

A (text)
Invoice #123 dated 2026-10-12
=REGEXEXTRACT(A2, "\d{4}-\d{2}-\d{2}")

Result: 2026-10-12 (as text; wrap in DATEVALUE() to turn it into a real date)

Example 3: Extract a US phone number

A (text)
Call Jane: (555) 987-6543 today
=REGEXEXTRACT(A2, "\(\d{3}\) \d{3}-\d{4}")

Result: (555) 987-6543

The brackets are escaped with a backslash because they are special characters in regex.

Example 4: Extract the domain from a URL

A (URL)
https://www.example.com/pricing
=REGEXEXTRACT(A2, "https?://(?:www\.)?([^/]+)")

Result: example.com

Only the text inside the normal parentheses is returned. The (?:...) part is a non-capturing group, so it is matched but not returned.

Example 5: Return several pieces at once

A (text)
AB123 $45.67
=REGEXEXTRACT(A2, "([A-Z]{2}\d{3})\s*\$(\d+\.\d{2})")

Result: two cells: AB123 and 45.67. Each capture group fills one column to the right.

Example 6: Handle rows with no match, for a whole column

Use IFERROR so rows without a date show a blank instead of #N/A, and ARRAYFORMULA to fill the whole range with one formula:

=ARRAYFORMULA(IFERROR(REGEXEXTRACT(A2:A10, "\d{4}-\d{2}-\d{2}"), ""))

Get every match, not just the first

REGEXEXTRACT stops at the first match. To list all numbers in abc123def456ghi789, replace everything that is not a digit with a space, then split:

=SPLIT(TRIM(REGEXREPLACE(A2, "[^0-9]+", " ")), " ")

Result: three cells across: 123, 456, 789.


Common problems

Problem Cause Fix
#N/A The pattern did not match Check the pattern, or wrap in IFERROR(..., "")
#VALUE! with "invalid regular expression" A special character such as ( or . is not escaped, or a bracket is unbalanced Put a backslash before it, for example \( or \., and check brackets match
Only the first match is returned That is how REGEXEXTRACT works Use the REGEXREPLACE and SPLIT method above
The result will not add up in a formula The extracted number is text Wrap in VALUE() or multiply by 1
Returns too much text A greedy pattern like .* takes as much as possible Use a more specific pattern such as [^/]+
Pattern works on regex tools but not here Google Sheets uses RE2, which lacks look-ahead and look-behind Rewrite the pattern with groups instead
Same formula in Excel gives #NAME? REGEXEXTRACT is Sheets only Use TEXTBEFORE, TEXTAFTER or MID in Excel

FAQ

What does REGEXEXTRACT do in Google Sheets?

It searches a text for a pattern and returns the first matching part. With capture groups in the pattern it returns only what the groups matched.

What is the difference between REGEXEXTRACT, REGEXMATCH and REGEXREPLACE?

REGEXEXTRACT returns the matching text. REGEXMATCH returns TRUE or FALSE depending on whether the pattern matches. REGEXREPLACE replaces the matching text with something else.

Does REGEXEXTRACT work in Excel?

No. It is a Google Sheets function. In Excel 365 you can use TEXTBEFORE, TEXTAFTER and TEXTSPLIT for simple extractions.

Is REGEXEXTRACT case sensitive?

Yes. To ignore case, start the pattern with (?i), for example (?i)invoice\s*(\d+).

How do I extract numbers from text in Google Sheets?

Use =REGEXEXTRACT(A2, "\d+") for the first number. For a number with decimals, use "\d+\.?\d*". Wrap the formula in VALUE() if you need to calculate with it.