Back to Packer

`replace` Function

website/content/docs/templates/hcl_templates/functions/string/replace.mdx

1.15.31.1 KB
Original Source

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

[!IMPORTANT]
Documentation Update: Product documentation previously located in /website has moved to the hashicorp/web-unified-docs repository, where all product documentation is now centralized. Please make contributions directly to web-unified-docs, since changes to /website in this repository will not appear on developer.hashicorp.com. ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

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

shell-session
> replace("1 + 2 + 3", "+", "-")
1 - 2 - 3

> replace("hello world", "world", "everybody")
hello everybody
  • regex_replace searches a given string for another given substring, and replaces each occurrence with a given replacement string.