Top  | Previous | Next

Strings / split

split(string, regex, [limit])

This function takes the string string and splits it into a bunch of substrings. The substrings are return as a dataset with one column called "parts". The split occurs wherever the regular expression regex occurs. Don't be intimidated by the regular expression, this is normally just another string, like "," for comma separated lists.

 

The optional limit argument, if greater than zero, limits the number of times the regex pattern is applied to limit-1. Put another way, it limits the length of the resulting dataset to length limit. If limit is non-positive then the regex pattern will be applied as many times as possible and the returned dataset can have any length. If limit is zero (the default) then the pattern will be applied as many times as possible, the returned dataset can have any length, and trailing empty strings will be discarded.

 

split("hello,world"",")

... returns

parts

"hello"

"world"

 

split("boo:and:foo"":")

... returns

parts

"boo"

"and"

"foo"

 

split("boo:and:foo"":", 2)

... returns

parts

"boo"

"and:foo"