Google Sheets Function: REGEXEXTRACT

The REGEXEXTRACT function extracts one or more parts of a text using regular expressions.


=REGEXEXTRACT(text, regular_expression)

If you are unfamiliar with what a regular expression is or how to write one, start by thoroughly reading the complete tutorial accompanying the REGEXMATCH function before proceeding (to save yourself some headaches when reading some of the regex on this page).

Extracting the First Word Found

The REGEXEXTRACT function here returns the first word found among the two possibilities ("fun" or "terrifying"):

google sheets function regexextract word

Extracting a Reference

This time, the REGEXEXTRACT function returns the part of the reference number matching the expression "[A-Z]\d{2}" (i.e., an uppercase letter followed by 2 digits):

google sheets function regexextract extract reference

Extracting a Number

The regex "\d*" corresponds to "all digits in unlimited quantity," meaning the function will extract all digits until encountering a non-digit character:

google sheets function regexextract numbers

Extracting at the End

To extract the digits at the end of the text this time, add a "$" to the end of the regex:

google sheets function regexextract numbers end

Extracting Multiple Parts

To extract the different groups of numbers, add parentheses around each part of the text to extract:

google sheets function regexextract extract multiple strings

Extracting in the Middle

For example, to extract the second group of numbers, the regex is as follows:


The addition of "?:", after the first parenthesis indicates it is non-capturing (so it won't return any value). There is then only one pair of parentheses left (thus only one value returned) and a quantifier of 2:

google sheets function regexextract non capturing parentheses