Contact

REGEXREPLACE Function in Google Sheets: Syntax, Examples & Compatibility

Text Beginner Google Sheets

Learn how to standardize inconsistent text by replacing regex-matched fragments in Google Sheets. Includes syntax, two verified-by-reasoning results, troubleshooting and portability notes.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Quick answer: standardize inconsistent text by replacing regex-matched fragments in Google Sheets. The reproducible examples below use explicit values so the formula’s meaning is testable without a large workbook.

Evidence: The function name and syntax are documented in the linked vendor function reference. Expected outputs were independently reasoned or checked outside the application. These are not native Google Sheets test results. A guide being published here does not certify every software release or file-import scenario.

Availability and version history

  • Introduced: Introduction version not established by the official history reviewed.
  • Availability: Documented in the rolling Google Sheets service; examples use the web spreadsheet workflow.
  • Checked: October 14, 2026; official REGEXREPLACE reference. Documentation check, not a new native test; existing example-verification notes retain their scope.

Syntax and arguments

=REGEXREPLACE(text, regular_expression, replacement)

All three arguments are required. Google specifies that every matching instance is replaced, and that both the input and result are text. A pattern matching one digit differs from a pattern matching a whole run of digits.

Best use case: Standardize inconsistent text by replacing regex-matched fragments.

Set up the example sheet

The fictional phone-style string below demonstrates digit substitution. Such replacement is not a guarantee of anonymization; other identifying text can remain.

Enter the formula in an unused cell. For a formula returning several values, leave an unobstructed area where those values can expand. These formulas use comma argument separators in a typical English-language locale; commas or semicolons inside quoted text are data, not argument separators. Adapt the separator if your regional settings require it.

Worked example 1: REGEXREPLACE with known input

=REGEXREPLACE("Phone 123-456","[0-9]","#")

Expected output: Phone ###-###.

Each digit is matched independently and replaced by a hash character.

Worked example 2: a second REGEXREPLACE case

=REGEXREPLACE("A  B"," +"," ")

Expected output: A B.

One or more consecutive normal spaces are replaced by a single space.

Compare both results before replacing literal values or short sample ranges with your own workbook data. For a spilling formula, compare every output cell, not only the top-left result.

Replace characters or runs deliberately

Compare these formulas on the same fictional string:

=REGEXREPLACE("Phone 123-456","[0-9]","#")
=REGEXREPLACE("Phone 123-456","[0-9]+","#")

Expected strings are Phone ###-### and Phone #-#. The first has six one-character matches; the second has two digit-run matches. Neither removes the word Phone or the hyphen.

With A12 B345, replacing [0-9]+ by X gives AX BX. Multiple matches are replaced in one call; this is different from REGEXEXTRACT’s first matching case.

Advanced example: collapse ordinary spaces, then trim

=REGEXREPLACE("  A   B  "," +"," ")

The expected text is " A B “, including one leading and one trailing ordinary space. Replacing runs by one space does not remove those edge spaces.

=TRIM(REGEXREPLACE("  A   B  "," +"," "))

Expected text: A B. These controls concern normal ASCII spaces, not every Unicode separator or nonbreaking space. Decide which characters should be treated as separators before expanding the pattern.

Advanced example: replace a literal metacharacter

=REGEXREPLACE("AB.204.CD","\.","-")

Expected text: AB-204-CD. The escaped dot matches punctuation. Using an unescaped dot instead would match each character in this single-line input and produce nine hyphens. The visually small pattern difference changes the operation completely.

When only a fixed literal phrase is involved, SUBSTITUTE avoids regex metacharacter interpretation.

Advanced example: cleaning can destroy meaning

=REGEXREPLACE("ID AB-004","[^0-9]","")

Expected text: 004. It retains the digits and removes every other character. That might be appropriate for an explicitly defined identifier transformation, but the same rule applied to -12.50 yields 1250, not the original signed decimal number.

Similarly, AB-12 and AB12 both become AB12 under a rule that removes hyphens. Normalization can merge distinct source strings. Keep the original field and transformation policy when identity matters; a successfully calculated replacement is not proof that the information was preserved.

Replacement capture references, empty-match patterns and literal-dollar/backslash escaping in replacement text are outside these controls. The examples use simple literal replacement strings so their meaning can be independently inspected.

Practical advice and troubleshooting

When this formula helps: To replace a fixed literal phrase without pattern syntax, SUBSTITUTE is generally simpler to read.

Important edge case: Regex metacharacters such as . and * have special meanings; escape them if your intent is a literal match.

If the result differs, first verify the text-versus-number types of the input cells, the argument separators for your locale, and the range size. For dynamic arrays, inspect occupied cells in the output area. For an imported file, check that the formula is being evaluated in Google Sheets and that its ranges and text survived conversion.

Compatibility and version considerations

Similar-looking regex functions in other programs may use different regular-expression dialects and replacement syntax.

Google Sheets is a rolling web service. Confirm the sheet locale and the full result area when checking an imported formula.

Function availability and parameter behavior must be judged for the specific application and release; a function documented in one spreadsheet does not automatically work in another.

RE2 scope

Google documents RE2 with Unicode character-class matching excluded in Sheets. The RE2 syntax reference supports the ASCII classes, grouping, repetition and anchors used here. Lookaround and backreferences inside a pattern are not supported by RE2. These controls do not certify other engines, arbitrary Unicode, replacement-group syntax or native error displays.

Editorial verification: Full dedicated reference and current manuscript reviewed October 14, 2026. Original and added outputs were independently calculated; no native application run, screenshot, or version-specific output is claimed. Review the editorial testing standards if you require stronger proof before importing a workbook.