Merge pull request #22042 from hashicorp/012-replace-regex-docs
Added regex details to replace() docs
This commit is contained in:
commit
275ecf96f2
|
@ -20,9 +20,19 @@ each occurrence with a given replacement string.
|
||||||
replace(string, substring, replacement)
|
replace(string, substring, replacement)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If `substring` is wrapped in forward slashes, it is treated as a regular
|
||||||
|
expression; the syntax conforms to the [re2 regular expression
|
||||||
|
syntax](https://github.com/google/re2/wiki/Syntax) syntax. If using a regular
|
||||||
|
expression for the substring argument, the `replacement` string can incorporate
|
||||||
|
captured strings from the input by using an `$n` sequence, where `n` is the
|
||||||
|
index or name of a capture group.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
```
|
```
|
||||||
> replace("1 + 2 + 3", "+", "-")
|
> replace("1 + 2 + 3", "+", "-")
|
||||||
1 - 2 - 3
|
1 - 2 - 3
|
||||||
|
|
||||||
|
> replace("hello world", "/w.*d/", "everybody")
|
||||||
|
hello everybody
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue