REGEXEXTRACT Function
Pulls out the text that matches a regular expression pattern.
Category
Text
Available in
Microsoft 365
Returns
Text, or an array that spills
Overview
REGEXEXTRACT finds text that fits a pattern and returns it — a phone number buried in a note, an order number in an email subject.
Return mode 1 returns every match and mode 2 returns the parts of the first match you've wrapped in brackets. Both spill across the row.
Syntax
Arguments
| Argument | Required? | What it does |
|---|---|---|
| text | Yes | The text to search. |
| pattern | Yes | The regular expression describing what to extract. |
| return_mode | Optional | 0 = first match (default), 1 = all matches, 2 = capture groups of the first match. |
| case_sensitivity | Optional | 0 = case-sensitive (default), 1 = ignore case. |
Examples
Example 1 — Phone numbers from notes
Each CRM note mentions a phone number somewhere.
| A | B | |
|---|---|---|
| 1 | Note | Phone |
| 2 | Call Ana on 604-555-0199 today | 604-555-0199 |
| 3 | Ben (403-555-0142) prefers email | 403-555-0142 |
Example 2 — Every order number
Return all order numbers mentioned in an email.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Order 1 | Order 2 | Order 3 | |
| 2 | Re: ORD-1001, ORD-1007 and ORD-1012 | ORD-1001 | ORD-1007 | ORD-1012 |
Example 3 — Splitting with capture groups
Pull the last and first names out of "Lopez, Ana".
Common mistakes
- #N/A when nothing matches. Wrap in IFERROR or IFNA to show a friendly message.
Notes
- Related functions: REGEXTEST, REGEXREPLACE, TEXTAFTER, MID.

Author
Kyle Stott
Certified Microsoft Excel Expert
Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.