Google Sheets REGEXREPLACE function
Replaces everything that matches a pattern. It is a Sheets-only function. It has the same name in Spanish Sheets.
Syntax
English Sheets
=REGEXREPLACE(text, regular_expression, replacement)
Spanish Sheets (Mexico locale)
=REGEXREPLACE(texto, expresión_regular, texto_reemplazo)
Spanish Sheets (Spain, Latin America)
=REGEXREPLACE(texto; expresión_regular; texto_reemplazo)
| Argument | What it is |
|---|---|
| text | The original text. |
| regular_expression | The pattern to replace. |
| replacement | What goes in its place; "" to delete. |
Example
REGEXREPLACE(text, regular_expression, replacement) replaces everything that matches the pattern. [^0-9] means "anything that is not a digit": replacing it with "" leaves only the numbers, whether there are hyphens, spaces or parentheses.
=REGEXREPLACE(A2,"[^0-9]","")
Common mistake
Special characters like . ( ) + need a backslash in front to be literal: "\."
About Ads
This site uses Google AdSense to display ads. These ads help us keep WebHerramientas completely free. Ads are managed by Google and meet strict security and privacy standards.
Ads help us keep WebHerramientas free for everyone
Practice REGEXREPLACE
Type the formula in the sheet and check it instantly. Spanish or English function names both work. See all lessons
REGEXREPLACE
REGEXREPLACE(text, regular_expression, replacement) replaces everything that matches the pattern. [^0-9] means "anything that is not a digit": replacing it with "" leaves only the numbers, whether there are hyphens, spaces or parentheses.
In B2, keep only the phone’s digits, removing every other character.
| A | B | C | |
|---|---|---|---|
| 1 | Phone as typed | Clean | |
| 2 | (55) 1234-5678 | ||
| 3 | 33 9876 5432 | ||
| 4 | 81.5555.0101 | ||
| 5 | +52 998 123 4567 | ||
| 6 | 222-765-4321 | ||
| 7 |
Tip: while typing, click a cell or drag across several to insert their reference.
Frequently asked questions
- What is REGEXREPLACE called in Spanish?
- It has the same name: REGEXREPLACE. Functions that started in Google Sheets keep their English name even in a Spanish spreadsheet. What changes is the separator: Spain and much of Latin America separate arguments with semicolons.
- Why does REGEXREPLACE use semicolons in some spreadsheets?
- It depends on each spreadsheet's locale, under File > Settings. Where the comma is the decimal mark (Spain, much of South America), arguments are separated by semicolons. Mexico and United States locales use commas.
- What is the most common REGEXREPLACE mistake?
- Special characters like . ( ) + need a backslash in front to be literal: "\."