Skip to main content

String array functions

5 functions on this page

Array[String] prefix(String, Array[P])

Adds a prefix to each element of the input array of primitive values. Equivalent to evaluating "~{prefix}~{array[i]}" for each i in range(length(array)).

String
The prefix to prepend to each element in the array.
Array[P]
Array with a primitive element type.
returns
An Array[String] with the prefixed elements of the input array.
Example
wdl
Array[String] names = ["John", "Jane", "world"]
String greetings = prefix("Hello, ", names)
# `greetings` now contains `["Hello, John", "Hello, Jane", "Hello, world"]`.

Array[String] suffix(String, Array[P])

Adds a suffix to each element of the input array of primitive values. Equivalent to evaluating "~{array[i]}~{suffix}" for each i in range(length(array)).

String
The suffix to append to each element in the array.
Array[P]
Array with a primitive element type.
returns
An Array[String] the suffixed elements of the input array.
Example
wdl
Array[String] names = ["John", "Jane"]
String responses = suffix(" says 'hi!'", names)
# `responses` now contains `["John says 'hi!'", "Jane says 'hi!'"]`.

Array[String] quote(Array[P])

Adds double-quotes (") around each element of the input array of primitive values. Equivalent to evaluating '"~{array[i]}"' for each i in range(length(array)).

Array[P]
Array with a primitive element type.
returns
An Array[String] the double-quoted elements of the input array.
Example
wdl
Array[String] numbers = [1, 2, 3]
String quoted = quote(numbers)
# `quoted` now contains `["\"1\"", "\"2\"", "\"3\""]`.

Array[String] squote(Array[P])

Adds single-quotes (') around each element of the input array of primitive values. Equivalent to evaluating "'~{array[i]}'" for each i in range(length(array)).

Array[P]
Array with a primitive element type.
returns
An Array[String] the single-quoted elements of the input array.
Example
wdl
Array[String] numbers = [1, 2, 3]
String quoted = squote(numbers)
# `quoted` now contains `["'1'", "'2'", "'3'"]`.

String sep(String, Array[P])

Concatenates the elements of an array together into a string with the given separator between consecutive elements. There are always N-1 separators in the output string, where N is the length of the input array. A separator is never added after the last element. Returns an empty string if the array is empty.

arg
String: Separator string.
arg
Array[P]: Array of strings to concatenate.
returns
A String with the concatenated elements of the array delimited by the separator string.
Example
wdl
Array[String] letters = ["a", "b", "c", "d"]
String letters_with_commas = sep(", ", letters)
# `letters_with_commas` now contains `"a, b, c, d"`.