lang/funcs: add 'strrev' interpolation function. (#21091)

This commit is contained in:
Kit Ewbank 2019-04-24 14:52:39 -04:00 committed by Kristin Laemmert
parent 9327eedb04
commit efc08de5d6
4 changed files with 38 additions and 0 deletions

View File

@ -99,6 +99,7 @@ func (s *Scope) Functions() map[string]function.Function {
"slice": funcs.SliceFunc,
"sort": funcs.SortFunc,
"split": funcs.SplitFunc,
"strrev": stdlib.ReverseFunc,
"substr": stdlib.SubstrFunc,
"timestamp": funcs.TimestampFunc,
"timeadd": funcs.TimeAddFunc,

View File

@ -25,3 +25,7 @@ with all of the same elements as the given sequence but in reverse order.
1,
]
```
## Related Functions
* [`strrev`](./strrev.html) reverses a string.

View File

@ -0,0 +1,29 @@
---
layout: "functions"
page_title: "strrev - Functions - Configuration Language"
sidebar_current: "docs-funcs-string-strrev"
description: |-
The strrev function reverses a string.
---
# `strrev` Function
`strrev` reverses the characters in a string.
Note that the characters are treated as _Unicode characters_ (in technical terms, Unicode [grapheme cluster boundaries](https://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries) are respected).
```hcl
strrev(string)
```
## Examples
```
> strrev("hello")
olleh
> strrev("a ☃")
☃ a
```
## Related Functions
* [`reverse`](./reverse.html) reverses a sequence.

View File

@ -87,6 +87,10 @@
<a href="/docs/configuration/functions/split.html">split</a>
</li>
<li>
<a href="/docs/configuration/functions/strrev.html">strrev</a>
</li>
<li>
<a href="/docs/configuration/functions/substr.html">substr</a>
</li>