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)

ArgumentWhat it is
textThe original text.
regular_expressionThe pattern to replace.
replacementWhat 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.

Advertising
Loading ad...

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.

Example=REGEXREPLACE(A2,"[^0-9]","")REGEXREPLACE: same name in Spanish

In B2, keep only the phone’s digits, removing every other character.

B2
ABC
1Phone as typedClean
2(55) 1234-5678
333 9876 5432
481.5555.0101
5+52 998 123 4567
6222-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: "\."