# replace

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: replace
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: sql/sql-functions/string-functions/replace
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/string-functions/replace.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/string-functions/replace.adoc
description: The `replace()` function looks for and replaces a substring with a new one in a string.
page-topic-type: reference
page-git-created-date: "2026-05-26"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/string-functions/replace.md -->

The `replace()` function looks for and replaces a substring with a new one in a string. This function is often used to update the outdated or spelling mistakes in data that require an amendment.

> 📝 **NOTE**
>
> Redpanda SQL also supports the [`regexp_replace()`](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/string-functions/regex/regexp-replace/) function. It searches and replaces a substring that matches with a POSIX regular expression

## [](#syntax)Syntax

The syntax for `replace()` function is:

```sql
REPLACE(string, old_substring, new_substring)
```

> ⚠️ **WARNING**
>
> The `replace()` function performs a case-sensitive replacement

### [](#parameters)Parameters

The syntax requires these parameters:

-   `string`: String to replace.

-   `old_substring`: Substring to replace. All occurrences in the string are replaced.

-   `new_substring`: New substring that will replace the old one.


## [](#examples)Examples

### [](#basic-usage)Basic usage

This example demonstrates a basic usage of the `replace()` function.

```sql
SELECT REPLACE ('NewDatabase', 'New', 'Redpanda');
```

The `replace()` function finds all occurrences of the ‘New’ substring in the ‘NewDatabase’ string and replaces it with the ‘Redpanda’ substring, producing:

```sql
+---------------------+
| f                   |
+---------------------+
| RedpandaDatabase    |
+---------------------+
```

### [](#replace-specified-values-in-a-table)Replace specified values in a table

This example shows how to replace the values of a specific column in a table. First, create a new table named **hobby** with **club** and **category** columns and insert the values into the respective columns.

```sql
CREATE TABLE hobby (
  club text,
  category text
);
INSERT INTO hobby
    (club, category)
VALUES
    ('Bridge','group'),
    ('Painting','individual'),
    ('Basketball','group'),
    ('Volleyball','group');
```

After that is completed, retrieve all values from the table using this query:

```sql
SELECT * FROM hobby;
```

```sql
+------------+---------------+
| club       | category      |
+------------+---------------+
| Bridge     | group         |
| Painting   | individual    |
| Basketball | group         |
| Volleyball | group         |
+--------------+-------------+
```

This query replaces the **‘group’** values in the **category** column with **‘sports’**:

```sql
SELECT REPLACE(category, 'group', 'sports') from hobby;
```

```sql
+--------------+
| f            |
+--------------+
| sports       |
| individual   |
| sports       |
| sports       |
+--------------+
```

### [](#remove-a-substring-from-a-string)Remove a substring from a string

This example shows how to remove a substring from a string using the `replace()` function. In this case, the goal is to find all occurrences of the ‘Friends’ substring in the ‘Hello Friends’ string and remove it:

```sql
SELECT REPLACE('Hello Friends', 'Friends', '');
```

```sql
+-----------+
| f         |
+-----------+
| Hello     |
+-----------+
```

### [](#replace-multiple-patterns)Replace multiple patterns

This example uses the `replace()` function to replace multiple patterns of the given string:

```sql
SELECT REPLACE(REPLACE(REPLACE(REPLACE('2*[9-5]/{4+8}', '[', '('), ']', ')'), '{', '('), '}', ')');
```

The `replace()` function is called multiple times to replace the corresponding string as specified:

-   **`[]`** into **`()`**

-   **`{}`** into **`()`**


```sql
+------------------+
| f                |
+------------------+
| 2*(9-5)/(4+8)    |
+------------------+
```