Extract Text with REGEXEXTRACT

Excel Formulas › Advanced

365 (2024+)REGEX

Pull exactly the piece you want — an order number, an email, a price — with a regular expression. REGEXEXTRACT brings true pattern matching to Excel formulas.


Quick formula: extract the first run of digits from A2:
=REGEXEXTRACT(A2, "[0-9]+")
The pattern [0-9]+ matches one or more digits; REGEXEXTRACT returns the first match found in the text.

Functions used (tap for the full reference guide):

The example

Pull the numeric ID out of a messy string.

AB
1TextExtracted
2Order #10456 shipped10456
3ID: AB-9999

The formula

Match a pattern and return it:

=REGEXEXTRACT(A2, "[0-9]+") // "Order #10456" → "10456"

How it works

A regular expression describes the shape of what to grab:

  1. The pattern is a regex: [0-9]+ = one or more digits, [A-Za-z]+ = letters, \w+ = word characters.
  2. REGEXEXTRACT scans the text and returns the first match.
  3. Use groups ( ) and a return-mode argument to grab a specific captured part or all matches.
  4. Combine character classes, quantifiers (+ * ?), and anchors (^ $) to target exactly the substring you need.

Email in one shot: =REGEXEXTRACT(A2, "[\w.]+@[\w.]+") pulls an address out of a sentence. REGEXEXTRACT is a 2024 addition to Excel 365 — in older versions, fall back to MID/FIND/SEARCH combinations.

Try it: interactive demo

Live demo

Pattern + text → first match.

Match:

Variations

Extract an email

Address from a sentence:

=REGEXEXTRACT(A2, "[\w.]+@[\w.]+")

A captured group

Return group 1:

=REGEXEXTRACT(A2, "ID-([0-9]+)", , 1)

All matches

Spill every match:

=REGEXEXTRACT(A2, "[0-9]+", 1)

Pitfalls & errors

365 (2024+) only. REGEXEXTRACT is a recent addition. Older Excel returns #NAME? — use MID/FIND/SEARCH there.

No match errors. If the pattern finds nothing, it returns #N/A — wrap with IFERROR for a clean blank.

Escape special characters. A literal dot or parenthesis in the pattern needs a backslash (\.), or it means “any character” / a group.

Practice workbook

📊
Download the free Extract Text with REGEXEXTRACT practice workbook
REGEXEXTRACT examples (formula text + result) with email, group, and all-matches variants, plus 4 challenges with answers. No sign-up required.

Frequently asked questions

How do I extract text with a pattern in Excel?
Use =REGEXEXTRACT(text, pattern). For example =REGEXEXTRACT(A2, "[0-9]+") returns the first run of digits. It needs Excel 365 (2024 or later).
How do I extract an email address from a cell?
Use =REGEXEXTRACT(A2, "[\w.]+@[\w.]+") to pull an address out of surrounding text.
What if the pattern finds nothing?
REGEXEXTRACT returns #N/A when there's no match. Wrap it in IFERROR to show a blank or message instead.

Stop fighting formulas. Learn them in a day.

This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related formulas: Extract numbers · REGEXREPLACE · Extract email domain

Function references: REGEXEXTRACT