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+"," ")
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Text | Other | Result | |
| 2 | Alice Johnson | alice johnson | extra spaces | |
| 3 | [email protected] | [email protected] | ||
| 4 | extra spaces | |||
| 5 | SKU-2026-0415 | |||
| 6 | iced coffee, tea, sugar | |||
| 7 | Order 417 shipped |
Result in D2: extra spaces