REGEXEXTRACT function in Excel
Extracts strings within the provided text that matches the pattern
=REGEXEXTRACT(text, pattern, [return_mode], [case_sensitivity])REGEXEXTRACT syntax and parameters
Four arguments, two required.
- textstringRequired
The text or the reference to a cell containing the text you want to extract strings from.
- patternstringRequired
The regular expression ("regex") that describes the pattern of text you want to extract.
- return_modenumberOptional
A number that specifies what strings you want to extract. By default, return mode is 0. The possible values are:0: Return the first string that matches the pattern1: Return all strings that match the pattern as an array2: Return capturing groups from the first match as an arrayNote: Capturing groups are parts of a regex pattern surrounded by parentheses "(...)". They allow you to return separate parts of a single match individually.
- case_sensitivitynumberOptional
Determines whether the match is case-sensitive. By default, the match is case-sensitive. Enter one of the following:0: Case sensitive1: Case insensitive
REGEXEXTRACT examples
Formulas you'll actually reuse.
The first run of digits in an order note:
=REGEXEXTRACT(A2, "[0-9]+")Result
"10422"Every email address in a block of text — return_mode 1 spills all matches:
=REGEXEXTRACT(A2, "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}", 1)
REGEXEXTRACT in Google Sheets
Same name — your formula ports as-is.
Try REGEXEXTRACT in the playground
Edit the example — nothing to install.
Preloaded with the REGEXEXTRACT formula from Example 1 — change anything and watch it respond.
REGEXEXTRACT errors
What they mean — and the fixes.
#N/ANothing matched — test the pattern with REGEXTEST first, or wrap in IFERROR for a blank.
Related functions
More ways Excel gets this done.
- ARRAYTOTEXTReturns an array of text values from any specified rangeTextNo Google Sheets equivalent
- CHARReturns the character specified by the code numberTextGoogle Sheets
- CLEANRemoves all nonprintable characters from textTextGoogle Sheets
- CODEReturns a numeric code for the first character in a text stringTextGoogle Sheets
- CONCATCombines the text from multiple ranges and/or strings, but it doesn't provide the delimiter or IgnoreEmpty arguments.TextGoogle Sheets
- CONCATENATEJoins several text items into one text itemTextGoogle Sheets