Main content

REGEXEXTRACT in Google Sheets, Pull Text

By Szabó Gergő · Updated

REGEXEXTRACT returns the first match of a regular expression. Excel does not use this name. Wrap misses with IFNA.

Syntax and arguments

=REGEXEXTRACT(text, regular_expression)
text
Cell or string that holds the source.
regular_expression
RE2 pattern. Parentheses mark the group you want.

REGEXEXTRACT examples

01
Domain from an email

Email in A2.

=REGEXEXTRACT(A2,"@(.+)")

Returns the part after @. Pair with ARRAYFORMULA to fill a column.

02
Invoice number

A2 contains INV-1044 somewhere.

=REGEXEXTRACT(A2,"INV-(\d+)")

Captures digits after INV-.

03
First word

A sentence in A2.

=REGEXEXTRACT(A2,"^(\S+)")

Returns the first run of non-space characters.

Common mistakes

  • Expecting every match

    REGEXEXTRACT returns one match. Run it twice or clean with REGEXREPLACE.

  • No fallback on a miss

    A failed pattern returns #N/A. Wrap with IFNA.

  • Excel-only syntax

    Older Excel uses MID and FIND. Newer Excel has its own REGEXEXTRACT in some builds.

REGEXEXTRACT FAQ

Does REGEXEXTRACT work in Excel?

Not under this name in older Excel. Microsoft 365 is adding regex functions. MID and FIND still work everywhere.

What happens when nothing matches?

Sheets returns #N/A. Wrap with IFNA or IFERROR.

Can I extract more than one group?

One call returns one match. Use a second REGEXEXTRACT or REGEXREPLACE for cleanup.