0PricingLogin
Excel Formulas Academy · Lesson

Replacing Patterns With REGEXREPLACE

Swap matched text for new values across a cell.

Rewriting Text by Pattern

So far you tested patterns and pulled pieces out. Now you will rewrite text: stripping junk characters, reformatting phone numbers, or collapsing extra spaces.

REGEXREPLACE finds every part of the text that matches a pattern and swaps it for replacement text you choose.

This Google Sheets function is the heavy lifter of text cleaning, because it can transform a whole messy column in one pass.

The REGEXREPLACE Syntax

REGEXREPLACE(text, pattern, replacement) takes three arguments: the source text, the pattern to find, and the replacement string.

Unlike REGEXEXTRACT, it replaces every match it finds, not just the first.

The formula below removes all digits from A2 by replacing each digit with an empty string. Room 204 becomes Room .

=REGEXREPLACE(A2, "\d", "")

All lessons in this course

  1. Testing Patterns With REGEXMATCH
  2. Pulling Out Patterns With REGEXEXTRACT
  3. Replacing Patterns With REGEXREPLACE
  4. Splitting and Cleaning Messy Data
← Back to Excel Formulas Academy