github.com/hugorut/terraform@v1.1.3/website/docs/language/functions/split.mdx (about)

     1  ---
     2  page_title: split - Functions - Configuration Language
     3  description: |-
     4    The split function produces a list by dividing a given string at all
     5    occurrences of a given separator.
     6  ---
     7  
     8  # `split` Function
     9  
    10  `split` produces a list by dividing a given string at all occurrences of a
    11  given separator.
    12  
    13  ```hcl
    14  split(separator, string)
    15  ```
    16  
    17  ## Examples
    18  
    19  ```
    20  > split(",", "foo,bar,baz")
    21  [
    22    "foo",
    23    "bar",
    24    "baz",
    25  ]
    26  > split(",", "foo")
    27  [
    28    "foo",
    29  ]
    30  > split(",", "")
    31  [
    32    "",
    33  ]
    34  ```
    35  
    36  ## Related Functions
    37  
    38  * [`join`](/language/functions/join) performs the opposite operation: producing a string
    39    joining together a list of strings with a given separator.