Skip to content

Commit

Permalink
Merge pull request #30483 from bpar476/patch-1
Browse files Browse the repository at this point in the history
Adds documentation to `substr` function to cover when `length` exceeds input length
  • Loading branch information
laurapacilio committed Feb 15, 2022
2 parents aed7162 + 252865c commit 68e70d7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion website/docs/language/functions/substr.mdx
Expand Up @@ -7,7 +7,7 @@ description: |-

# `substr` Function

`substr` extracts a substring from a given string by offset and length.
`substr` extracts a substring from a given string by offset and (maximum) length.

```hcl
substr(string, offset, length)
Expand Down Expand Up @@ -36,3 +36,11 @@ string after the given offset will be returned.
> substr("hello world", -5, -1)
world
```

If the length is greater than the length of the string, the substring
will be the length of all remaining characters.

```
> substr("hello world", 6, 10)
world
```

0 comments on commit 68e70d7

Please sign in to comment.