The REGEXEXTRACT function is officially available only on Excel 365, but thanks to Modern Functions Update (MFU) you can now run it on your Excel 2007, 2010, 2013, 2016, 2019, 2021 and 2024 versions. It works exactly as its original Microsoft counterpart.
Description
The REGEXEXTRACT function extracts text from a string based on a provided regular expression pattern. For the advanced Excel user, this function is a major upgrade. Instead of working out complex formulas based on functions like LEFT, RIGHT, FIND, MID, etc., REGEXEXTRACT can target data very precisely with a single regex pattern.
You can extract the first match, all matches, or capturing groups from the first match.
This is particularly useful for:
- Extracting numbers: Pull digits from alphanumeric strings
- Parsing emails: Extract email addresses from text
- Extracting phone numbers: Pull phone numbers in various formats
- Extracting URLs: Get website addresses from text
- Extracting dates: Pull dates in various formats
- Data cleaning: Extract specific patterns from messy data
Syntax
=REGEXEXTRACT(text, pattern, [return_mode], [case_sensitivity])

Basic Tokens Reference
Examples
Basic Usage – Extracting Numbers
To extract a number from a text string:
=REGEXEXTRACT("10 apples", "[0-9]+")
Returns: "10"
The pattern [0-9]+ means “match one or more characters, where each character is a digit from 0 to 9”. You can also use the more compact pattern \d+.
Converting to a Numeric Value
REGEXEXTRACT always returns text values. To convert to a number:
=VALUE(REGEXEXTRACT(A1, "\d+"))
Extracting Names Based on Capital Letters
With the pattern [A-Z][a-z]+:
=REGEXEXTRACT("DylanWilliams", "[A-Z][a-z]+")
Returns: "Dylan"
=REGEXEXTRACT("DylanWilliams", "[A-Z][a-z]+", 1)
Returns: "Dylan" and "Williams" (spilled across two cells).
Extracting Phone Numbers
To extract phone numbers in the format (XXX) XXX-XXXX:
=REGEXEXTRACT("Sonia Rees (378) 555-4195", "[0-9()]+ [0-9-]+", 1)
Returns the phone number (378) 555-4195.
For phone numbers in format XXX-XXX-XXXX:
=REGEXEXTRACT(B5, "\d{3}-\d{3}-\d{4}")
Extracting Email Addresses
To extract an email address:
=REGEXEXTRACT(A2, "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}")
Case-Insensitive Search
By default, REGEXEXTRACT is case-sensitive. To ignore case:
=REGEXEXTRACT(A2, "excel", , 1)
Return All Matches
To return all matches instead of just the first:
=REGEXEXTRACT(A2, "#\w+", 1)
This extracts all hashtags from a text string.
Extracting URLs
To extract URLs from text:
=REGEXEXTRACT(A3, "(https?://|www\.)\S+")
Handling “Not Found”
If no match is found, REGEXEXTRACT returns a #N/A error. To handle this:
=IFERROR(REGEXEXTRACT(A1, "\d+"), "No number found")
Capturing Groups
To extract specific parts of a match using capturing groups, set return_mode to 2:
=REGEXEXTRACT(B5, "(\d{4})-(\w+)-(\w+)", 2)
This returns each capturing group (the parts in parentheses) as separate values.
Practical Use Cases
| Scenario | Formula |
|---|---|
| Extract first number | =REGEXEXTRACT(A1, "\d+") |
| Extract all numbers | =REGEXEXTRACT(A1, "\d+", 1) |
| Extract email address | =REGEXEXTRACT(A1, "[\w\.-]+@[\w\.-]+\.\w+") |
| Extract URL | =REGEXEXTRACT(A1, "(https?://|www\.)\S+") |
| Extract phone number | =REGEXEXTRACT(A1, "\(\d{3}\)\s\d{3}-\d{4}") |
| Extract hashtags | =REGEXEXTRACT(A1, "#\w+", 1) |
| Extract date (MM/DD/YYYY) | =REGEXEXTRACT(A1, "\b\d{1,2}/\d{1,2}/\d{2,4}\b") |
| Case-insensitive search | =REGEXEXTRACT(A1, "pattern", , 1) |
Notes
- ✅ Fully tested – The implementation in Modern Functions Update works identically to Microsoft’s original function introduced in Microsoft 365.
- ✅ The function is fully compatible with Excel 2007, 2010, and all later versions.
- ℹ️
REGEXEXTRACTuses the PCRE2 flavor of regular expressions. - ℹ️
REGEXEXTRACTalways returns text values. UseVALUEto convert to numbers. - ℹ️
REGEXEXTRACTis case-sensitive by default. Usecase_sensitivity = 1for case-insensitive matching. - ℹ️ If no match is found,
REGEXEXTRACTreturns#N/A. - ⚠️ When
return_modeis set to1or2, results spill across adjacent cells as a dynamic array. - ℹ️ Capturing groups (parts of a regex pattern enclosed in parentheses
(...)) allow you to return separate parts of a single match individually.
See Also
REGEXTEST– Tests if text matches a regex patternREGEXREPLACE– Replaces text that matches a regex patternTEXTBEFORE– Extracts text before a delimiterTEXTAFTER– Extracts text after a delimiterTEXTSPLIT– Splits text into multiple valuesIFNA– Handles#N/Aerrors gracefully