github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/website/content/docs/job-specification/hcl2/functions/string/split.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: split - Functions - Configuration Language
     4  sidebar_title: 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  `split` produces a list by dividing a given string at all occurrences of a
    13  given separator.
    14  
    15  ```hcl
    16  split(separator, string)
    17  ```
    18  
    19  ## Examples
    20  
    21  ```shell-session
    22  > split(",", "foo,bar,baz")
    23  [
    24    "foo",
    25    "bar",
    26    "baz",
    27  ]
    28  > split(",", "foo")
    29  [
    30    "foo",
    31  ]
    32  > split(",", "")
    33  [
    34    "",
    35  ]
    36  ```
    37  
    38  ## Related Functions
    39  
    40  - [`join`](/docs/job-specification/hcl2/functions/string/join) performs the opposite operation: producing a string
    41    joining together a list of strings with a given separator.