REGEXREPLACE function
Replace text matched by a regular expression.
This reference covers the native Excel function. Its required application features or connected services are not implemented by the local worksheet engine. Check the linked Microsoft documentation for availability and complete option values.
Syntax
REGEXREPLACE(text, pattern, replacement, [occurrence], [case_sensitivity])Square brackets indicate optional arguments.
Arguments
| Argument | Required | Meaning |
|---|---|---|
| text | Yes | Text to examine or process. |
| pattern | Yes | A regular expression describing the text to match; Excel uses PCRE2 syntax. |
| replacement | Yes | Text inserted for each selected match; consult Microsoft documentation for capture references. |
| occurrence | No | Controls which matching occurrence is replaced. |
| case_sensitivity | No | Controls whether uppercase and lowercase characters are distinguished. |
Try REGEXREPLACE
Collapse repeated ordinary spaces
=REGEXREPLACE(A2,"[ ]+"," ")Each run of one or more ordinary spaces is replaced by one space. This preserves the slash and the surrounding words. Tabs and other whitespace are outside this particular pattern.
Inspect the current formula
Read its written arguments or observe actual operation values in a separate local calculation. This action neither applies a draft nor grades an answer.
Read the formula, one argument at a time
Explore the written function calls and their inputs. The calculation result belongs to the complete formula.
REGEXREPLACE · top-level call
=REGEXREPLACE(A2,"[ ]+"," ")Follow the cells behind a result
Read explicit local references and helper formulas using a separate calculation. Your draft stays in this field; the worksheet and practice checks do not change.
The worksheet runs locally. Published checks apply to the supplied example only. Native Excel and Google Sheets compatibility remain unverified.
Reference and compatibility
Original SheetTutor reference notes / Microsoft documentation. Calculation checks cover the supplied examples only. The browser worksheet does not implement every Excel feature, external service or connected data type.