WorkbookLogic
FunctionDynamic ArrayadvancedREGEXEXTRACTIFAND

REGEXEXTRACT Function

By WorkbookLogic

REGEXEXTRACT extracts text that matches a regular-expression pattern. Optional modes return the first match, all matches, or separate capture groups.

ExcelLast reviewed Sep 11, 2026
regexextract-function-v1.0.0.xlsx
Excel REGEXEXTRACT Function
REGEXEXTRACT returns a first match, all matches, or capture groups from text using a regex pattern.
Text and patterns, editableExamples
TextPatternReturn modeCase modeExampleFormula syntaxResult 1Result 2Result 3
Order AB-2048 shipped[A-Z]{2}-[0-9]{4}00Order code=REGEXEXTRACT(A12,B12,C12,D12)AB-2048
Call 555-123-4567 today[0-9]{3}-[0-9]{3}-[0-9]{4}00Phone number=REGEXEXTRACT(A13,B13,C13,D13)555-123-4567
Tags: #excel #data #tips#[A-Za-z]+10All hashtags=REGEXEXTRACT(A14,B14,C14,D14)#excel#data#tips
INV-2026-North([0-9]{4})-([A-Za-z]+)20Capture groups=REGEXEXTRACT(A15,B15,C15,D15)2026North
Reliability checks
The order-code pattern returns AB-2048OK
Capture-group mode returns year and region separatelyOK

Overview

REGEXEXTRACT returns text that matches a regular-expression pattern and can spill multiple matches or capture groups into adjacent cells.

Quick reference

Syntax: =REGEXEXTRACT(text, pattern, [return_mode], [case_sensitivity])

Returns: Matching text or a spilled array of matches or capture groups. (array)

Arguments:

  • text (required) — Text from which content is extracted.
  • pattern (required) — Regular expression that defines the match.
  • return_mode (optional) — 0 returns the first match, 1 all matches, and 2 capture groups.
  • case_sensitivity (optional) — 0 is case-sensitive and 1 ignores case.

The text and pattern are required. Optional return and case-sensitivity modes control whether Excel returns the first match, all matches, or capture groups and whether letter case matters.

Common uses

  • Extracting identifiers from descriptive text
  • Pulling phone numbers or similar structured tokens
  • Returning repeated tags or isolated capture groups

Calculations

Excel applies pattern to text. The default return mode is 0, which returns only the first match. Mode 1 returns every match as a spilled array, while mode 2 returns the content of parenthesized capture groups separately.

Regex patterns use character classes, quantifiers, anchors, groups, and other metacharacters. A pattern that finds no match returns #N/A.

Function behavior

Situation

Behavior

Omitted return mode

Returns the first match.

Return mode 1

Spills all matches.

Return mode 2

Spills capture groups.

Omitted case setting

Matching is case-sensitive.

No match

Returns #N/A.

Blocked spill range

Returns #SPILL!.

Common errors

Expecting all matches by default

What happens: Only the first match is returned.
Better approach: Set return_mode to 1.

Using a pattern that is too broad

What happens: Unintended text is extracted.
Better approach: Test progressively, add boundaries or tighter character classes, and keep sample edge cases visible.

Example

Example 1

=REGEXEXTRACT(A12,B12,C12,D12)

The pattern [A-Z]{2}-[0-9]{4} extracts AB-2048 from Order AB-2048 shipped.

Example 2

=REGEXEXTRACT(A13,B13,C13,D13)

A three-part digit pattern extracts 555-123-4567 from surrounding text.

Example 3

=REGEXEXTRACT(A14,B14,C14,D14)

With return mode 1, #[A-Za-z]+ spills #excel, #data, and #tips across three cells.

Example workbook

The workbook demonstrates a scalar order code, a phone number, all-match hashtags, capture groups, editable modes, and two formula-driven checks.

Key takeaway

Use REGEXEXTRACT when text follows a recognizable pattern, and choose the return mode deliberately when multiple outputs are required.