2020-02-06 11:49:21 +01:00
|
|
|
---
|
2020-03-18 18:46:47 -04:00
|
|
|
layout: docs
|
|
|
|
|
page_title: replace - Functions - Configuration Language
|
2020-04-02 19:39:47 -04:00
|
|
|
sidebar_title: replace
|
2020-02-06 11:49:21 +01:00
|
|
|
description: |-
|
|
|
|
|
The replace function searches a given string for another given substring,
|
|
|
|
|
and replaces all occurrences with a given replacement string.
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# `replace` Function
|
|
|
|
|
|
|
|
|
|
`replace` searches a given string for another given substring, and replaces
|
|
|
|
|
each occurrence with a given replacement string.
|
|
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
|
replace(string, substring, replacement)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
2020-05-29 17:12:05 -04:00
|
|
|
```shell-session
|
2020-02-06 11:49:21 +01:00
|
|
|
> replace("1 + 2 + 3", "+", "-")
|
|
|
|
|
1 - 2 - 3
|
|
|
|
|
|
2020-03-10 16:01:18 +01:00
|
|
|
> replace("hello world", "world", "everybody")
|
2020-02-06 11:49:21 +01:00
|
|
|
hello everybody
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Related Functions
|
|
|
|
|
|
2020-06-05 13:17:18 -04:00
|
|
|
- [`regex_replace`](/docs/from-1.5/functions/string/regex_replace) searches a given string for another given substring,
|
2020-03-10 10:51:25 -07:00
|
|
|
and replaces each occurrence with a given replacement string.
|