Splits a String
into pieces and returns an array containing the pieces.
splitTokens()
is an enhanced version of split(). It can split a string when any characters from a list are detected.
The first parameter, value
, is the string to split.
The second parameter, delim
, is optional. It sets the character(s) that should be used to split the string. delim
can be a single string, as in splitTokens('rock...paper...scissors...shoot', '...')
, or an array of strings, as in splitTokens('rock;paper,scissors...shoot, [';', ',', '...'])
. By default, if no delim
characters are specified, then any whitespace character is used to split. Whitespace characters include tab (\t
), line feed (\n
), carriage return (\r
), form feed (\f
), and space.
Ejemplos
Sintaxis
splitTokens(value, [delim])
Parámetros
string to split.
character(s) to use for splitting the string.