2018-05-07 03:32:16 +02:00
|
|
|
---
|
2021-12-15 03:41:17 +01:00
|
|
|
page_title: split - Functions - Configuration Language
|
2018-05-07 03:32:16 +02:00
|
|
|
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.
|
2018-05-07 03:32:16 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
# `split` Function
|
|
|
|
|
2019-03-21 20:20:29 +01:00
|
|
|
`split` produces a list by dividing a given string at all occurrences of a
|
2018-05-07 03:32:16 +02:00
|
|
|
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
|
2018-05-07 03:32:16 +02:00
|
|
|
joining together a list of strings with a given separator.
|