Home/Formulas/Text/REGEXREPLACE
Textmedium

REGEXREPLACE()

Replaces every match of a regular expression with the replacement text.

Syntax
fx
=REGEXREPLACE(text, regular_expression, replacement)
Arguments
ArgumentDescription
textThe text to operate on.
regular_expressionThe RE2 regular expression to match. Use $1, $2 in replacement for capture groups.
replacementThe text to insert in place of each match.
Example
fx
=REGEXREPLACE("abc123", "\d+", "X")

Paste this into Google Sheets to run it. The live playground on this site covers 24 of the 61 functions, and REGEXREPLACE isn't one of them yet.

Related formulas
REGEXMATCH()
Returns TRUE if a piece of text matches a regular expression.
REGEXEXTRACT()
Returns the first matching substring (or first capture group) of a regular expression.
SUBSTITUTE()
Replaces existing text with new text in a string. Match by content.
Used by
SUBSTITUTE()
Replaces existing text with new text in a string. Match by content.
REGEXMATCH()
Returns TRUE if a piece of text matches a regular expression.
REGEXEXTRACT()
Returns the first matching substring (or first capture group) of a regular expression.