---
title: "replace function in Strata | Oplema"
description: "Replace every occurrence of one piece of text with another. For example, replace('hello', 'l', '-') returns 'he--o'. Works in a Strata Formula or Filter."
url: "https://oplema.com/docs/strata/functions/replace"
updated: "2026-11-04"
---

# replace

Replace every occurrence of one piece of text with another.

## Try an expression

In [Formula](https://oplema.com/docs/strata/prep/formula), enter the expression and set Output type to **VARCHAR**.

### Expression

```
replace('hello', 'l', '-')
```

### Result

```
'he--o'
```

To use your own data, replace the example values with column names. Keep format strings and other options as written.

Try it live in Formula

Result
| id | result |
| --- | --- |
| 1 | he--o |

## Arguments and types

```
replace(string, source, target)
```

**string**

Text

**source**

Text

**target**

Text

Supported signatures (1)

```
replace(string: VARCHAR, source: VARCHAR, target: VARCHAR) → VARCHAR
```

The result type can depend on the input types. See DuckDB for the full argument rules.

## Things to know

If the first argument is missing, the result is NULL.

## Related functions

[translate

Swap individual characters: each character in the second argument becomes the character at the same position in the third. Characters with no counterpart are removed.

](https://oplema.com/docs/strata/functions/translate)[lpad

Add a character to the left of text until it reaches a given length. Longer text is cut from the right to that length.

](https://oplema.com/docs/strata/functions/lpad)[ltrim

Remove spaces from the start of text. Pass a second argument to remove those characters instead.

](https://oplema.com/docs/strata/functions/ltrim)[prefix

Check whether text begins with a given string.

](https://oplema.com/docs/strata/functions/prefix)

[Browse text](https://oplema.com/docs/strata/functions#text) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/text.html#replacestring-source-target)

Function metadata from DuckDB, used under the [MIT license](https://github.com/duckdb/duckdb/blob/v1.5.4/LICENSE).
