terraform/website/docs/language/functions/split.mdx

40 lines
650 B
Plaintext
Raw Normal View History

---
2021-12-15 03:41:17 +01:00
page_title: split - Functions - Configuration Language
description: |-
The split function produces a list by dividing a given string at all
2019-03-21 20:20:29 +01:00
occurrences of a given separator.
---
# `split` Function
2019-03-21 20:20:29 +01:00
`split` produces a list by dividing a given string at all occurrences of a
given separator.
```hcl
split(separator, string)
```
## Examples
```
> split(",", "foo,bar,baz")
[
"foo",
"bar",
"baz",
]
> split(",", "foo")
[
"foo",
]
> split(",", "")
[
"",
]
```
## Related Functions
2021-12-15 03:41:17 +01:00
* [`join`](/language/functions/join) performs the opposite operation: producing a string
joining together a list of strings with a given separator.