# REGEXEXTRACT function in Google Sheets

> REGEXEXTRACT pulls out the part of the text that matches a regular expression.

Source: https://spreadsheetpractice.com/google-sheets/functions/regexextract · Updated October 28, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on November 20, 2026

## Quick answer

- **What it does:** REGEXEXTRACT pulls out the part of the text that matches a regular expression.
- **Syntax:** `=REGEXEXTRACT(text, regular_expression)`
- **Most common use:** `=REGEXEXTRACT(A2,"@(.+)$")` returns acme.com (The capture group returns just the domain, everything after the @)
- **Works in:** Google Sheets only
- **Returns:** Text: the first match, or the captured group or groups. #N/A when nothing matches.

## What it does

REGEXEXTRACT pulls out the part of the text that matches a regular expression. Put parentheses around the piece you want and it returns just that group, which makes it a quick way to grab an order number, a domain or a code from messy text.

## Syntax

`=REGEXEXTRACT(text, regular_expression)`

| Argument | Required? | What it is |
|---|---|---|
| `text` | Required | The text to search. It has to be text: wrap numbers in TO_TEXT. |
| `regular_expression` | Required | The pattern to find. With one capture group in parentheses, only that group comes back; with several, each group fills its own cell. |

## Examples

Each result was calculated by running the formula on the sample sheet in Google Sheets mode.

| Cell | Formula | Result | What it shows |
|---|---|---|---|
| B2 | `=REGEXEXTRACT(A2,"@(.+)$")` | acme.com | The capture group returns just the domain, everything after the @ |
| B3 | `=REGEXEXTRACT(A3,"\d+")` | 4412 | The first run of digits, 4412, returned as text |
| B4 | `=REGEXEXTRACT(A4,"(\w+)-(\d+)")` | INV (spills 1 × 2) | Two capture groups fill two cells: INV in B4 and 2087 in C4 |

### The sample sheet

Every formula above runs on this data:

|  | A | B | C |
|---|---|---|---|
| 1 | Text | Result |  |
| 2 | ana@acme.com | acme.com |  |
| 3 | Order #4412 shipped | 4412 |  |
| 4 | Ref INV-2087 paid | INV | 2087 |

## Common mistakes

| What you see | Why, and how to fix it |
|---|---|
| #N/A | Nothing in the text matched. Check the pattern, or show a fallback: =IFNA(REGEXEXTRACT(A2,"\d+"),""). |
| The extracted number won't add up | REGEXEXTRACT always returns text. Wrap it in VALUE: =VALUE(REGEXEXTRACT(A2,"\d+")). |
| #VALUE! on a number | Like the other REGEX functions, it needs text. Use TO_TEXT(A2) as the first argument. |
| Only the first match comes back | REGEXEXTRACT stops at the first match. To get more, add capture groups for each piece, or remove what you don't want with REGEXREPLACE. |

## Tips

- Start the pattern with (?i) to ignore capitals.
- Group without returning the group with (?:...): "(?:Mr|Ms)\.? (\w+)" returns just the name after the title.

## REGEXEXTRACT in Excel

Recent Microsoft 365 builds have their own REGEXEXTRACT, with extra arguments for returning every match or the capture groups. Other versions use TEXTBEFORE and TEXTAFTER, or MID with FIND.

See [the Excel REGEXEXTRACT function](https://spreadsheetpractice.com/functions/regexextract).

## Questions

### How do I extract numbers from text in Google Sheets?

=REGEXEXTRACT(A2,"\d+") returns the first run of digits as text. Wrap it in VALUE to use it as a number, and use "\d+\.?\d*" to include decimals.

### How do I extract the domain from an email address?

=REGEXEXTRACT(A2,"@(.+)$") returns everything after the @.

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
