Skip to content
ExcelExcel Microsoft 365+

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.

  1. The first run of digits in an order note:

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

    Result"10422"

  2. 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.

Loading the editor…

REGEXEXTRACT errors

What they mean — and the fixes.

  • #N/A

    Nothing matched — test the pattern with REGEXTEST first, or wrap in IFERROR for a blank.