REGEXREPLACE Function in Google Sheets: Syntax, Examples & Compatibility
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: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Google Sheets. 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.
Syntax and arguments
=REGEXREPLACE(text, regular_expression, replacement)
text is the input string; the regex finds matching substrings; replacement supplies the substituted text.
Best use case: Standardize inconsistent text by replacing regex-matched fragments.
Set up the example sheet
Imagine phone or customer-reference strings with sensitive digits that need masking before a screenshot is shared.
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.
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. An error that looks like a missing function may reflect a software version rather than incorrect data.
Compatibility and version considerations
Similar-looking regex functions in other programs may use different regular-expression dialects and replacement syntax.
Check your installed release for availability and dynamic-array support.
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.
Related guides and official documentation
-
Google Sheets documentation for REGEXREPLACE — function syntax and current vendor information.
Editorial verification: Vendor catalogue referenced as of 2026-10-12. The two example outputs are independently reasoned; 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.