Top index Wirbel home

::split

string.split(string delimiter) - split a string into parts by a delimiter
string.split(char delimiter) - split string at a character
string.split(string delimiter, int maxcnt) - split string into at most maxcnt + 1 parts
string.split(char delimiter, int maxcnt) - split string into at most maxcnt + 1 parts at a character
list(A).split(delimiter, int maxcnt) - split list into list of lists
list(A).split(delimiter) - split list into list of at most maxcnt + 1 lists
string.split() - split at groups of white spaces

string.split(string delimiter) splits up astring into a list of substrings that are delimited by delimiter. If astring is empty, a list with one empty string is returned.

string.split(char delimiter) is a variant that uses a single character as delimiter

string.split(string delimiter, int maxcnt) is a variant that allows you to specify maxcnt - a maximum count of parts to be split off. The length of the result is at most maxcnt plus one.

string.split(char delimiter, int maxcnt) is a variant that uses a single character as delimiter

list(A).split(delimiter, int maxcnt) is a variant that does not split a string but a list.

list(A).split(delimiter) is a variant that lets you limit the number of parts

string.split() is special variant of split that does not use a specific delmiter but splits a string into parts by groups of one or more white spaces. Note that this is not the same as split(' '), since the later one interpretes sequences of whitespaces as multiple delimiters while split() interpretes those as only one delimiter.

Examples

"::two::three".split("::") == [ "", "two", "three" ]

 "one,two,three".split(",", 1) == [ "one", "twothree" ]

 [ 1, 0, 2, 3, 0, 4 ].split(0) == [ [ 1 ], [ 2, 3 ], [ 4 ] ]

 [ 1, 0, 2, 3, 0, 4 ].split(0, 1) == [ [ 1 ], [ 2, 3, 0, 4 ] ]

 " one two   three  ".split() == ["one", "two", "three"]
 "  ".split() == []

See also

bisplit