REGEXREPLACE

Replaces part of a text string with a different text string using regular expressions.

Sample Usage

REGEXREPLACE("Spreadsheets", "S.*d", "Bed")

Syntax

REGEXREPLACE(text, regular_expression, replacement)

text - The text, a part of which will be replaced.

regular_expression - The regular expression. All matching instances in text will be replaced.

replacement - The text which will be inserted into the original text.

Notes

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 VALUE function in conjunction with this function. If numbers are used as input, convert them to text using the TEXT function.

See Also

REGEXEXTRACT: Extracts matching substrings according to a regular expression.

Using Google products, like Google Docs, at work or school? Try powerful tips, tutorials, and templates. Learn to work on Office files without installing Office, create dynamic project plans and team calendars, auto-organize your inbox, and more.