# replace

Source: https://zotonic.com/docs/1559/replace

URI: https://zotonic.com/id/1559

Language: en



Regular expression replacement of a pattern with a string.

Replaces the sub strings matching a regular expression with a new string value.

For example:

```django
{{ "abcba"|replace:["b","x"] }}
```

The output will be the string “axcxa”.

If you do not specify the replacement value, the replacement value is assumed to be the empty string:

```django
{{ "abcba"|replace:"b" }}
```

The output will be the string “aca”.

::: {.note title="Note"}
This filter is inefficient, as it will compile and match a regular expression while serving the template. Try to do string replacements when you save your content, and not when you serve the content.
:::

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/1559?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/1559?language=en>)
