> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for REPLACE function

# REPLACE

Replaces all occurrences of the `<pattern>` substring within the `<expression>` with the `<replacement>` substring.

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
REPLACE (<expression>, <pattern, <replacement>)
```

## Parameters

| Parameter       | Description                                                                                                                                                                                | Supported input types |
| :-------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------- |
| `<expression>`  | The original string that will be searched for instances of the `<pattern>`.                                                                                                                | `TEXT`                |
| `<pattern>`     | The substring to be searched and replaced in the string.                                                                                                                                   | `TEXT`                |
| `<replacement>` | The substring to replace the original substring defined by `<pattern>`. To remove the `<pattern>` substring with no replacement, you can use a empty string `''` as the replacement value. | `TEXT`                |

## Examples

In the example below, "two" in "Level two" is replaced with "three".

<div className="query-window">
  ```
  SELECT REPLACE('Level two', 'two', 'three') AS level;
  ```

  | level <span>text</span> |
  | :---------------------- |
  | Level three             |

  <p><span>Rows: 1</span><span>Execution time: 5.75ms</span></p>
</div>

In this example, "eight" is replaced by an empty string.

<div className="query-window">
  ```
  SELECT REPLACE('Level eight', ' eight', '') AS level;
  ```

  | level <span>text</span> |
  | :---------------------- |
  | Level                   |

  <p><span>Rows: 1</span><span>Execution time: 5.54ms</span></p>
</div>

In this example, the substring "five" is not found in the original string, so the string is returned unchanged.

<div className="query-window">
  ```
  SELECT REPLACE('Level four', 'five', 'six') AS level;
  ```

  | level <span>text</span> |
  | :---------------------- |
  | Level four              |

  <p><span>Rows: 1</span><span>Execution time: 5.20ms</span></p>
</div>
