- All Implemented Interfaces:
- Function
public class SplitFunction
extends FunctionBase
implements Function
From http://docs.jsonata.org/string-functions.html:
$split(str, separator [, limit])
Splits the str parameter into an array of substrings. If str is not
specified, then the context value is used as the value of str. It is an error
if str is not a string.
The separator parameter can either be a string or a regular expression
(regex). If it is a string, it specifies the characters within str about
which it should be split. If it is the empty string, str will be split into
an array of single characters. If it is a regex, it splits the string around
any sequence of characters that match the regex.
The optional limit parameter is a number that specifies the maximum number of
substrings to include in the resultant array. Any additional substrings are
discarded. If limit is not specified, then str is fully split with no limit
to the size of the resultant array. It is an error if limit is not a
non-negative number.
Examples
$split("so many words", " ")==[ "so", "many", "words" ] $split("so many
words", " ", 2)==[ "so", "many" ] $split("too much, punctuation. hard; to
read", "[ ,.;]+")==["too", "much", "punctuation", "hard", "to", "read"]