You're looking at documentation for Terraform v1.1 and earlier. Click here to view the latest content.
A new platform for documentation and tutorials is launching soon.
We are migrating Terraform documentation into HashiCorp Developer, our new developer experience.
replace searches a given string for another given substring, and replaces
each occurrence with a given replacement string.
replace(string, substring, replacement)
substring is wrapped in forward slashes, it is treated as a regular
expression, using the same pattern syntax as
regex. If using a regular expression for the substring
replacement string can incorporate captured strings from
the input by using an
$n sequence, where
n is the index or name of a
> replace("1 + 2 + 3", "+", "-") 1 - 2 - 3 > replace("hello world", "/w.*d/", "everybody") hello everybody
regexsearches a given string for a substring matching a given regular expression pattern.