What REGEXREPLACE does
REGEXREPLACE replaces text inside a string based on a regular expression pattern. It is useful when simple find-and-replace logic is not flexible enough and you need pattern-based cleanup.
Practical examples
Mask the first part of a phone number
=REGEXREPLACE(A2,"[0-9]+-","***-")
This replaces the leading digit group and keeps the rest of the string unchanged.
Reorder first and last names with capture groups
=REGEXREPLACE(A2,"([A-Z][a-z]+)([A-Z][a-z]+)","$2, $1")
This uses capture groups to rearrange matched parts of the text.
Common mistakes and notes
REGEXREPLACE is available only in newer Excel builds
Microsoft lists this function only for Excel for Microsoft 365 and Excel for Microsoft 365 for Mac.
Occurrence defaults to all matches
If you omit occurrence, Excel uses 0, which means every match is replaced rather than only the first one.
Case sensitivity uses numeric flags
By default the match is case-sensitive. Use the optional argument when you want a case-insensitive replacement.