diff --git a/lang/functions.go b/lang/functions.go index bcda0e2966..7806f2921e 100644 --- a/lang/functions.go +++ b/lang/functions.go @@ -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, diff --git a/website/docs/configuration/functions/reverse.html.md b/website/docs/configuration/functions/reverse.html.md index a272932ee6..d9febecad9 100644 --- a/website/docs/configuration/functions/reverse.html.md +++ b/website/docs/configuration/functions/reverse.html.md @@ -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. diff --git a/website/docs/configuration/functions/strrev.html.md b/website/docs/configuration/functions/strrev.html.md new file mode 100644 index 0000000000..630a682630 --- /dev/null +++ b/website/docs/configuration/functions/strrev.html.md @@ -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. diff --git a/website/layouts/functions.erb b/website/layouts/functions.erb index 50f65c61bd..8365673723 100644 --- a/website/layouts/functions.erb +++ b/website/layouts/functions.erb @@ -87,6 +87,10 @@ split +
  • + strrev +
  • +
  • substr