mirror of
https://github.com/opentffoundation/opentf.git
synced 2026-04-24 18:00:57 -04:00
Previously we just listed out all of the functions in alphabetical order inside the "Interpolation Syntax" page, but that format doesn't leave much room for details and usage examples. Now we give each function its own page, and categorize them for easier navigation. While many functions are very simple and don't really warrant a full page, certain functions do have additional details that are worth mentioning and this structure scales better for those more complicated functions. So far this includes only the numeric and string functions. Other categories will follow in subsequent commits.
42 lines
672 B
Markdown
42 lines
672 B
Markdown
---
|
|
layout: "functions"
|
|
page_title: "split function"
|
|
sidebar_current: "docs-funcs-string-split"
|
|
description: |-
|
|
The split function produces a list by dividing a given string at all
|
|
occurences of a given separator.
|
|
---
|
|
|
|
# `split` Function
|
|
|
|
`split` produces a list by dividing a given string at all occurences of a
|
|
given separator.
|
|
|
|
```hcl
|
|
split(separator, string)
|
|
```
|
|
|
|
## Examples
|
|
|
|
```
|
|
> split(",", "foo,bar,baz")
|
|
[
|
|
"foo",
|
|
"bar",
|
|
"baz",
|
|
]
|
|
> split(",", "foo")
|
|
[
|
|
"foo",
|
|
]
|
|
> split(",", "")
|
|
[
|
|
"",
|
|
]
|
|
```
|
|
|
|
## Related Functions
|
|
|
|
* [`join`](./join.html) performs the opposite operation: producing a string
|
|
joining together a list of strings with a given separator.
|