<< Go back to all functions

REGEXREPLACE

The REGEXREPLACE function in Google Sheets is a powerful tool to replace part of a text string with a different text string using regular expressions. Whether you're cleaning up data, extracting specific patterns, or modifying text, the REGEXREPLACE function simplifies the task. Dive into our comprehensive guide to master its application.

Function Syntax and Parameters

Syntax: REGEXREPLACE(text, regular_expression, replacement)

Parameters:

  • text: The text or reference to a cell containing the text to be replaced.
  • regular_expression: The regular expression pattern to be matched within the text.
  • replacement: The replacement text or reference to a cell containing the replacement text.

Step-by-Step Tutorial

  1. Basic usage with literal text:

    • Example: =REGEXREPLACE("Hello World", "World", "Universe")
    • Result: "Hello Universe"
  2. Using cell references for text and replacement:

    • Example: If A1 contains the text "Hello World" and B1 contains "World", then =REGEXREPLACE(A1, B1, "Universe") will return "Hello Universe".

Use Cases and Scenarios

  1. Data Cleaning: Remove unwanted characters, symbols, or patterns from a text.
  2. Data Extraction: Extract specific patterns from a text using regular expressions.
  3. Text Modification: Replace or modify part of a text string based on a pattern.

Related Functions

  • REGEXMATCH: Matches a text string against a regular expression pattern.
  • REGEXEXTRACT: Extracts a matching substring based on a regular expression pattern.

Related Articles