FormulaCamp
Completed
← All functions
Text

REGEXREPLACE

Replaces matches; $1 is the first group in parentheses.

Syntax

REGEXREPLACE(text, pattern, replacement, [occurrence], [case_sensitivity])

Example: =REGEXREPLACE(A2,"\s+"," ")

Available in: Microsoft 365 only

Try it

A tiny spreadsheet with example data. Edit the formula or any number and see the result.

Formula in D2: =REGEXREPLACE(A4,"\s+"," ")

Example spreadsheet for REGEXREPLACE
ABCD
1TextOtherResult
2Alice Johnsonalice johnson extra spaces
3alice@shop.comALICE@shop.com
4 extra spaces
5SKU-2026-0415
6iced coffee, tea, sugar
7Order 417 shipped
Result in D2: extra spaces
Practice this in a lesson: REGEX Functions

More in Text