FormulaCraft

REGEXREPLACE

REGEXREPLACE finds all occurrences within a text string that match a regular expression pattern and replaces them with a specified replacement string. It is a Google Sheets-only function used for advanced text cleaning — such as removing punctuation, stripping HTML tags, normalising whitespace, or masking sensitive data.

Excel
=SUBSTITUTE(SUBSTITUTE(A2,"!",""),"?","")
Google Sheets
=REGEXREPLACE(A2,"[^a-zA-Z0-9 ]","")

Verified example

Computed by a real spreadsheet engine on the sample data below.

Raw TextCleaned
Hello, World!Hello World
Price: $9.99Price 999
Name (2024)Name 2024
test@email.comtestemailcom

=SUBSTITUTE(SUBSTITUTE(A2,"!",""),"?","")Hello, World

Try it with your data

Edit the grid or formula, then run it through a real spreadsheet engine — no signup.

Sample data — click any cell to edit

Runs server-side · free · no signup

How it works

  1. 1In Google Sheets, identify the cells containing text you want to clean and define a regex pattern for what should be removed or replaced.
  2. 2Enter =REGEXREPLACE(A2,"[^a-zA-Z0-9 ]","") to strip all characters that are not letters, digits, or spaces.
  3. 3Supply a non-empty replacement string to swap matched patterns: =REGEXREPLACE(A2,"\s+"," ") collapses multiple spaces into one.

Need a version for your data?

Try: “Remove all special characters from a column of product descriptions

Related

Written and reviewed by FormulaCraft Team. Each formula on this page is run through our verification engine before publishing.

Last reviewed: