Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of Clarify single-removal behavior in trimsuffix and trimprefix docs into v1.10 #36042

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading