what happens when prefix is not in string

https://github.com/hashicorp/terraform/blob/master/lang/functions.go#L126 shows that Terraform's Trimprefix comes directly from the standard go library. 
When prefix is absent in the go standard library, the original string is returned; https://golang.org/pkg/strings/#TrimPrefix.
This commit is contained in:
jessica-ritter 2020-06-22 11:31:08 -07:00 committed by GitHub
parent 43737f2f4f
commit edbf59ed4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -13,7 +13,7 @@ description: |-
earlier, see
[0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html).
`trimprefix` removes the specified prefix from the start of the given string.
`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.
## Examples
@ -22,6 +22,11 @@ earlier, see
world
```
```
> trimprefix("helloworld", "cat")
helloworld
```
## Related Functions
* [`trim`](./trim.html) removes characters at the start and end of a string.