github.com/rstandt/terraform@v0.12.32-0.20230710220336-b1063613405c/website/docs/configuration/functions/split.html.md (about) 1 --- 2 layout: "functions" 3 page_title: "split - Functions - Configuration Language" 4 sidebar_current: "docs-funcs-string-split" 5 description: |- 6 The split function produces a list by dividing a given string at all 7 occurrences of a given separator. 8 --- 9 10 # `split` Function 11 12 -> **Note:** This page is about Terraform 0.12 and later. For Terraform 0.11 and 13 earlier, see 14 [0.11 Configuration Language: Interpolation Syntax](../../configuration-0-11/interpolation.html). 15 16 `split` produces a list by dividing a given string at all occurrences of a 17 given separator. 18 19 ```hcl 20 split(separator, string) 21 ``` 22 23 ## Examples 24 25 ``` 26 > split(",", "foo,bar,baz") 27 [ 28 "foo", 29 "bar", 30 "baz", 31 ] 32 > split(",", "foo") 33 [ 34 "foo", 35 ] 36 > split(",", "") 37 [ 38 "", 39 ] 40 ``` 41 42 ## Related Functions 43 44 * [`join`](./join.html) performs the opposite operation: producing a string 45 joining together a list of strings with a given separator.