Calc REGEXREPLACE function

Replaces substrings that match a regular expression with a specified replacement string.

Help CentreFunctions & Formulas

For a full list of available calculation functions, please read What calculation functions are supported.

This article describes the formula syntax and usage of the REGEXREPLACE function.


Description

Replaces substrings that match a regular expression with a specified replacement string.


Syntax

REGEXREPLACE(text, regular_expression, replacement)


The REGEXREPLACE function has the following arguments:
  • text - Required. The text to search for matches.
  • regular_expression - Required. The regular expression to match against text.
  • replacement - Required. The string to replace each match with.

Remarks

  • If there are no matches, REGEXREPLACE returns the original text.
  • The regular expression must match the entire text string. If you want to replace only part of the text, use parentheses in the regular expression to capture the part you want to replace.

Example

FormulaDescriptionResult
=REGEXREPLACE("abc123", "[0-9]+", "XYZ")Replaces the first sequence of digits in "abc123" with "XYZ".abcXYZ

Errors

For a full list of formula errors, please read Formula errors.


Related functions

See it working on your own data

Everything documented here ships with the platform – try the document tools free, or go live in 7 days.