Extracts the first matching substrings according to a regular expression.
=REGEXEXTRACT("My favorite number is 241, but my friend's is 17", "\d+")
Tip: REGEXEXTRACT will return "241" in this example because it returns the first matching case.
text- The input text.
regular_expression- The first part of
textthat matches this expression will be returned.
- Google products use RE2 for regular expressions. Google Sheets supports RE2 except Unicode character class matching. Learn more on how to use RE2 expressions.
- This function only works with text (not numbers) as input and returns text as output. If a number is desired as the output, try using the
VALUEfunction in conjunction with this function. If numbers are used as input, convert them to text using the
REGEXMATCH: Whether a piece of text matches a regular expression.
REGEXREPLACE: Replaces part of a text string with a different text string using regular expressions.
SUBSTITUTE: Replaces existing text with new text in a string.
REPLACE: Replaces part of a text string with a different text string.