Merge pull request #22042 from hashicorp/012-replace-regex-docs

Added regex details to replace() docs
This commit is contained in:
Chris Arcand 2019-07-12 12:46:31 -05:00 committed by GitHub
commit 275ecf96f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -20,9 +20,19 @@ each occurrence with a given replacement string.
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
```
> replace("1 + 2 + 3", "+", "-")
1 - 2 - 3
> replace("hello world", "/w.*d/", "everybody")
hello everybody
```