Skip to content

Commit

Permalink
Merge pull request #36042 from hashicorp/backport/main/quickly-desire…
Browse files Browse the repository at this point in the history
…d-filly

Backport of Clarify single-removal behavior in `trimsuffix` and `trimprefix` docs into v1.10
  • Loading branch information
crw authored Nov 18, 2024
2 parents 11e0983 + 975ff1d commit dda67dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 6 additions & 1 deletion website/docs/language/functions/trimprefix.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down
12 changes: 11 additions & 1 deletion website/docs/language/functions/trimsuffix.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand Down

0 comments on commit dda67dd

Please sign in to comment.