Back to Packer

`endswith` Function

website/content/docs/templates/hcl_templates/functions/string/endswith.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. ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

endswith Function

endswith takes two values: a string to check and a suffix string. The function returns true if the first string ends with that exact suffix.

hcl
endswith(string, suffix)

Examples

> endswith("hello world", "world")
true
> endswith("hello world", "hello")
false
  • startswith takes two values: a string to check and a prefix string. The function returns true if the string begins with that exact prefix.