Excel REGEXREPLACE Function: Syntax, Examples & Tips

The REGEXREPLACE function replaces text patterns in a string using regular expressions for efficient data manipulation in Excel.
Excel
=REGEXREPLACE(text, regular_expression, replacement)

One free generation or explanation per browser, shared across Excel and Google Sheets. Account usage limits apply afterward.

Need more than a single REGEXREPLACE formula? Try our free AI for Excel — it reads your entire spreadsheet, answers questions in plain English, and builds charts and analysis in the same chat.

On this page
  1. Parameters
  2. What is a REGEXREPLACE Formula in Excel?
  3. A Practical Example
  4. REGEXREPLACE Formula
  5. Result of the Formula
  6. Why Use REGEXREPLACE?
  7. Key Takeaways:
  8. Example use case

Parameters

text:
The input text or cell reference that you want to search and modify using the regular expression.

regular_expression:
The pattern that defines the search criteria for the text. This is a string that specifies the regular expression to match against the text.

replacement:
The text that will replace the matched portions of the text based on the regular_expression.

What is a REGEXREPLACE Formula in Excel?

The REGEXREPLACE function in Excel is a powerful tool that allows you to replace text in a string based on a regular expression pattern. It evaluates a given text, searches for a specified pattern, and replaces it with a new string if the pattern is found.

In simpler terms, the REGEXREPLACE function helps you manipulate text data by finding and replacing specific patterns, making it easier to clean and format your data.

A Practical Example

Imagine you are working with a list of email addresses in an Excel spreadsheet, and you have the following data:

Email Data Table:

You want to replace the domain "example.com" with "newdomain.com" for all email addresses.

REGEXREPLACE Formula

To replace the domain for the email addresses, you would use the REGEXREPLACE formula as follows:

Excel
=REGEXREPLACE(A2, "@example\.com$", "@newdomain.com")

Breakdown of the Formula:

  • A2: This is the cell containing the email address you want to modify.
  • "@example.com$": This is the regular expression pattern that defines which part of the text to search for. The \ is used to escape the dot, and $ indicates the end of the string.
  • "@newdomain.com": This is the string that will replace the matched pattern.

Result of the Formula

When you apply the formula, it replaces the domain "example.com" with "newdomain.com" for the email addresses. The output would be:

Here, the email addresses for Alice, Bob, and Eve have been updated, while Charlie and David remain unchanged since their domains do not match.

Why Use REGEXREPLACE?

The REGEXREPLACE function is particularly useful when you need to perform complex text manipulations based on patterns without manually editing each entry. It allows you to quickly clean and format data, making it easier to prepare datasets for analysis.

Key Takeaways:

  • REGEXREPLACE: Replaces text based on a specified regular expression pattern.
  • Efficient Text Manipulation: Helps you quickly modify strings without manual editing.
  • Common Use Cases: Ideal for data cleaning, formatting, and any scenario where you need to replace specific text patterns.

Understanding how to use the REGEXREPLACE function can significantly enhance your data manipulation capabilities in Excel, enabling you to efficiently clean and format your datasets.

Happy replacing!

Example use case

You have a dataset in Column A that contains email addresses of customers, but some entries have inconsistent formatting, such as extra spaces or incorrect casing. You can use the REGEXREPLACE function to clean up these email addresses by removing extra spaces and converting them to lowercase. This ensures that all email addresses are standardized, making it easier to manage customer communications and maintain a clean database without the need for manual corrections.

Beyond the REGEXREPLACE function: Better Analyst is a full Excel AI that goes well past individual formulas. Upload any spreadsheet and ask questions in plain English — you'll get formulas, data analysis, and charts back in seconds. It's a free AI Excel assistant that works with any .xlsx, .xls, or .csv file — no plugins, no Microsoft 365 required.

Don't have a spreadsheet yet? Use our free AI spreadsheet generator to turn a text prompt into a downloadable Excel file — a full AI Excel sheet maker that builds headers, columns, and formulas from your description.

Need more help with Excel formulas?

Create a free account for formula help, explanations, and spreadsheet analysis. Usage limits depend on your plan.

Explore all Excel formulas

Browse our complete library of Excel formula guides

Compare your options

Decide with evidence, not a sales pitch.

Open a neutral research prompt in the AI tool you already use. Compare capabilities, limitations, and fit before you choose.

  1. 01ChatGPTOpen a balanced comparison prompt in ChatGPT.
  2. 02ClaudeOpen the same research prompt in Claude.
  3. 03PerplexityResearch the comparison with linked web sources.

AI answers can be incomplete. Check source links, current pricing, and product documentation before deciding.