Text

Google Sheets REGEXEXTRACT Function — Syntax, Examples & Tips

Learn how to use REGEXEXTRACT in Google Sheets to pull text matching a regular expression pattern. Includes syntax, examples, and common mistakes.

Syntax
=REGEXEXTRACT(text, regular_expression)

What REGEXEXTRACT Does

REGEXEXTRACT pulls the first substring that matches a regular expression pattern from a text string. Where REGEXMATCH tells you whether a pattern exists, REGEXEXTRACT gives you the actual matching text. It is invaluable for extracting structured data from messy strings — pulling numbers out of descriptions, isolating domains from URLs, or grabbing dates embedded in free-form text.

Syntax

=REGEXEXTRACT(text, regular_expression)
ParameterDescription
textThe string to search within.
regular_expressionThe regex pattern describing what to extract. If the pattern contains a capture group (parentheses), only the captured portion is returned.

Basic Examples

Extract a number from text

AB
1DescriptionNumber
2Invoice #4821=REGEXEXTRACT(A2, "\d+")
3Qty: 250 units=REGEXEXTRACT(A3, "\d+")

Results:

Number
4821
250

The \d+ pattern matches one or more consecutive digits.

Pull the domain from an email

AB
1EmailDomain
2lisa@example.com=REGEXEXTRACT(A2, "@(.+)")
3raj@startup.io=REGEXEXTRACT(A3, "@(.+)")

Results:

Domain
example.com
startup.io

The parentheses create a capture group. REGEXEXTRACT returns only what is inside the parentheses — everything after the @.

Extract a date from a sentence

A
1Meeting scheduled for 04/15/2026 in Room B
=REGEXEXTRACT(A1, "\d{2}/\d{2}/\d{4}")

Result: 04/15/2026

The pattern \d{2}/\d{2}/\d{4} matches a date in MM/DD/YYYY format.

Advanced Examples

Extract multiple groups at once

If your pattern contains multiple capture groups, REGEXEXTRACT returns them in separate cells (spilling horizontally):

=REGEXEXTRACT(A2, "(\w+)\s(\w+)")

For A2 = "John Smith", this returns John in one cell and Smith in the adjacent cell. Each set of parentheses creates a separate output column. This is a powerful alternative to SPLIT when the delimiter is inconsistent but the data structure follows a predictable pattern.

Extract a URL from mixed text

Suppose you have cells with notes that contain URLs buried in sentences:

=REGEXEXTRACT(A2, "(https?://[^\s]+)")

For A2 = "See details at https://example.com/report?id=42 for more info", this returns https://example.com/report?id=42. The pattern starts matching at http:// or https:// and continues until it hits a whitespace character.

Common Mistakes

  • Getting a #N/A error when no match is found. If the pattern does not exist in the text, REGEXEXTRACT returns an error rather than an empty string. Wrap it with IFERROR to handle this gracefully: =IFERROR(REGEXEXTRACT(A2, "\d+"), "No number found").
  • Forgetting that REGEXEXTRACT is case-sensitive. Searching for "error" will not match "Error" or "ERROR". Use (?i) at the start of the pattern for case-insensitive matching: =REGEXEXTRACT(A2, "(?i)error\w*").
  • Confusing the full match with capture groups. Without parentheses, the entire match is returned. With parentheses, only the captured portion is returned. =REGEXEXTRACT("ID:123", "ID:(\d+)") returns 123, not ID:123. If you want the full match including the prefix, remove the parentheses or wrap the whole pattern in a group.

SheetAI Tip

Don't want to memorize this syntax? With SheetAI, just type what you need in plain English and the formula is generated for you. Install SheetAI to try it free.

Skip the formula. Describe what you need.

SheetAI lets you type what you want in plain English and generates the perfect formula — no syntax to memorize.

Try SheetAI Free