参考 splitTokens()

splitTokens()

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.

示例

语法

splitTokens(value, [delim])

参数

value

string to split.

delim

character(s) to use for splitting the string.

Notice any errors or typos? Please let us know. Please feel free to edit src/utilities/string_functions.js and open a pull request!

相关参考