Wauvel

Excel like a finance pro.

← The library

Text function

REGEXEXTRACT

Extracts text matching a regular expression.

OccasionalDifficulty 1550 · AdvancedUsage rank #232 of 520
Practice · 3 questions →

When to use it

Pulls the text that matches a regular expression: the first match by default, all matches, or the capture groups.

The shape of it

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

Worked examples

  • First number

    =REGEXEXTRACT("Order 12345 shipped","\d+") 12345

    The first run of digits.

  • All matches

    =REGEXEXTRACT("a@x.com, b@y.org","[\w.]+@[\w.]+",1) {a@x.com, b@y.org}

    Mode 1 returns every match.

  • Capture groups

    =REGEXEXTRACT("2025-03-15","(\d+)-(\d+)-(\d+)",2) {2025, 03, 15}

    Mode 2 returns the capture groups.

Worth knowing

  • Test the pattern with REGEXTEST first.
  • Case-insensitive matching is the last argument.
  • Requires Microsoft 365 (2024).

Where it goes wrong

  • #N/A when nothing matches.
  • Backslashes in patterns do not need doubling in Excel, unlike in code.

Related

Learn the moves here — or let Wauvel run them on your numbers.

Meet your AI CFO →

One CFO-grade Excel tip a week

A short, practical email for finance operators — functions, shortcuts, and the moves that save an afternoon. Free, unsubscribe anytime.