string.split()

Split a String at a provided separator.

Signature

split(separator: String) => Array<String>

Description

Splits the calling String at every occurrence of a provided separator. Returns an array of the resulting Strings.

The separator isn’t preserved in the results. The calling String isn’t changed.

Parameters

Parameter Type Required Description

separator

String

true

Separator to split the calling string[] at. Splits at every occurrence of the separator.

Return value

Type Description

Array<String>

Array of Strings resulting from the split. The separator isn’t preserved in the results.

Examples

'foobarbaz'.split('b')
[
  "foo",
  "ar",
  "az"
]
\