github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/hcl2/functions/string/split.mdx (about)

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