Excel REGEXEXTRACT Function Tutorial

Version: Microsoft 365
Last update:
Tip: Use ⬆️ ⬇️ to turn the page up and down. We recommend browsing with a large screen for a better reading experience.

1. Introduction to the REGEXEXTRACT Function

The REGEXEXTRACT function in Excel is a powerful tool for extracting specific information from text strings using regular expressions (regex).

This function is particularly useful for parsing structured data, such as phone numbers, emails, and dates, allowing you to automate data processing tasks and enhance data analysis capabilities.
Introduction to the REGEXEXTRACT Function

2. Parameters of the REGEXEXTRACT Function

Here is the syntax for using the REGEXEXTRACT function.
=REGEXEXTRACT(text, pattern, [return_mode], [case_sensitivity])
  • text: required The text or the reference to a cell containing the text you want to extract strings from.
  • pattern: required The regular expression ("regex") that describes the pattern of text you want to extract.
  • return_mode: optional 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 pattern
  • 1: Return all strings that match the pattern as an array
  • 2: Return capturing groups from the first match as an array
  • Note: Capturing groups are parts of a regex pattern surrounded by parentheses "(...)". They allow you to return separate parts of a single match individually.
  • case_sensitivity: optional Determines whether the match is case-sensitive. By default, the match is case-sensitive. Enter one of the following:
  • 0: Case sensitive
  • 1: Case insensitive
  • 3. Example Scenario: Extracting Phone Numbers

    In this tutorial, we will demonstrate how to use the REGEXEXTRACT function to extract phone numbers from a list.
    Example Scenario: Extracting Phone Numbers

    4. Getting Started with the REGEXEXTRACT Function

    Type on your keyboard: =REGEXEXTRACT(, then select A5 as the text to be processed.
    Getting Started with the REGEXEXTRACT Function

    5. Input the Regular Expression

    To extract phone numbers, we input: \(\d{3}\)\s?\d{3}[-\s]?\d{4} as the regular expression.

    Explanation of phone number regex: Common Regular Expressions for Excel Users
    Input the Regular Expression
    REGEXEXTRACT Function Takes Effect
    Apply to Other Cells
    Extract All Matches
    Capture Groups
    Introduction to the REGEXEXTRACT Function