Merge pull request #35900 from rfalke/main

Clarify single-removal behavior in `trimsuffix` and `trimprefix` docs
equivalence-testing/main
Craig Wright 2 years ago committed by GitHub
commit fcac00654d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -7,7 +7,7 @@ description: |-
# `trimprefix` Function
`trimprefix` removes the specified prefix from the start of the given string. If the string does not start with the prefix, the string is returned unchanged.
`trimprefix` removes the specified prefix from the start of the given string, but only once. If the string does not begin with the prefix, the original string is returned unchanged.
## Examples
@ -21,6 +21,11 @@ world
helloworld
```
```
> trimprefix("--hello", "-")
-hello
```
## Related Functions
* [`trim`](/terraform/language/functions/trim) removes characters at the start and end of a string.

@ -7,7 +7,7 @@ description: |-
# `trimsuffix` Function
`trimsuffix` removes the specified suffix from the end of the given string.
`trimsuffix` removes the specified suffix from the end of the given string, but only once, even if the suffix appears multiple times. If the suffix does not appear at the very end of the string, the original string is returned unchanged.
## Examples
@ -16,6 +16,16 @@ description: |-
hello
```
```
> trimsuffix("helloworld", "cat")
helloworld
```
```
> trimsuffix("hello--", "-")
hello-
```
## Related Functions
* [`trim`](/terraform/language/functions/trim) removes characters at the start and end of a string.

Loading…
Cancel
Save