TextMicrosoft 365

REGEXREPLACE

Replace portions of text identified by a regular-expression pattern.

Syntax

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

Worked example

Replace each run of spaces with one hyphen.

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

Result A-12-B

Microsoft documentation

Check the arguments, supported editions and behavior of this function in Microsoft’s reference.

Microsoft reference

Search ExcelTutor