Keep only the digits
| A | |
|---|---|
| 1 | Phone |
| 2 | (415) 555-0100 |
Formula: C2: =REGEXREPLACE(A2,"\D","")
Result: 4155550100
The backslash-D class means any non-digit; replacing it with nothing removes it.
Google Sheets REGEXREPLACE takes exactly three arguments: the text, the regular expression and the replacement.
It uses RE2 syntax, which has no lookahead or lookbehind, and the same family includes REGEXMATCH and REGEXEXTRACT.
The arguments and common errors are covered in the REGEXREPLACE Excel guide; check the function help in Google Sheets for its own argument list.
| A | |
|---|---|
| 1 | Phone |
| 2 | (415) 555-0100 |
Formula: C2: =REGEXREPLACE(A2,"\D","")
Result: 4155550100
The backslash-D class means any non-digit; replacing it with nothing removes it.
| A | |
|---|---|
| 1 | Text |
| 2 | a b c |
Formula: C2: =REGEXREPLACE(A2,"\s+"," ")
Result: a b c
Every run of whitespace becomes one space.
| A | |
|---|---|
| 1 | Name |
| 2 | Lee, Ana |
Formula: C2: =REGEXREPLACE(A2,"(\w+), (\w+)","$2 $1")
Result: Ana Lee
The two captured words are written back in reverse order.
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 |
Google Sheets is used here only as a descriptive product name. FormulaCamp is not affiliated with Google.
Enter — commit · F2 — edit · F4 — $ in a reference · Ctrl+C/Ctrl+V — copy and paste · Ctrl+Z — undo
Esc or F6 — leave the sheet for the «Check» button · Shift+Tab in the first cell — back to the page