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.
[0-9]+ matches one or more digits; REGEXEXTRACT returns the first match found in the text.
The example
Pull the numeric ID out of a messy string.
| A | B | |
|---|---|---|
| 1 | Text | Extracted |
| 2 | Order #10456 shipped | 10456 |
| 3 | ID: AB-99 | 99 |
The formula
Match a pattern and return it:
How it works
A regular expression describes the shape of what to grab:
- The pattern is a regex:
[0-9]+= one or more digits,[A-Za-z]+= letters,\w+= word characters. - REGEXEXTRACT scans the text and returns the first match.
- Use groups
( )and a return-mode argument to grab a specific captured part or all matches. - 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
Pattern + text → first match.
Variations
Extract an email
Address from a sentence:
A captured group
Return group 1:
All matches
Spill every match:
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
Frequently asked questions
How do I extract text with a pattern in Excel?
How do I extract an email address from a cell?
What if the pattern finds nothing?
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