REGEXREPLACE function
Replaces strings within the provided text that matches the pattern with replacement.
Text · Microsoft 365
Where can you use it?
Data preparation and reporting teams. Use this group to clean, split or reformat IDs, names and descriptions before using them in reports.
Scenario in the workbook
Mask the numeric portion of exported IDs while keeping the prefix visible.
A worked example from the workbook
| Row | A |
|---|---|
| 6 | Input |
| 7 | INV-42 |
| 8 | INV-004 |
| 9 | PO-125 |
Record 1
=REGEXREPLACE(A7,"[0-9]+","xxx")Expected resultINV-xxx
See the inputs and instructions for all 3 examplesCopyable formulas
English Excel · en-US
=REGEXREPLACE("INV-042","[0-9]+","125")Turkish Excel · tr-TR
=NORMİFADEDEĞİŞTİR("INV-042";"[0-9]+";"125")Expected result
“INV-125”
Worked examples
Mask the numeric portion of exported IDs while keeping the prefix visible.
Open the English sheet. Inputs begin at A6. F7:F9 show the live results and G7:G9 show the original results for comparison.
| Row | A |
|---|---|
| 6 | Input |
| 7 | INV-42 |
| 8 | INV-004 |
| 9 | PO-125 |
| Case | Formula | Expected result |
|---|---|---|
| Record 1 | =REGEXREPLACE(A7,"[0-9]+","xxx") |
INV-xxx |
| Record 2 | =REGEXREPLACE(A8,"[0-9]+","xxx") |
INV-xxx |
| Record 3 | =REGEXREPLACE(A9,"[0-9]+","xxx") |
PO-xxx |