---
title: "replace | Grafana Agent documentation"
description: "Learn about replace"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# replace

`replace` searches a string for a substring, and replaces each occurrence of the substring with a replacement string.

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
replace(string, substring, replacement)
```

## Examples

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
> replace("1 + 2 + 3", "+", "-")
"1 - 2 - 3"
```
