split()
split()
converts the "subject" string into a node-set of <token>
elements. The optional pattern is a Perl-compatible regular expression (without delimiters). It is used to split the input string. If no pattern is given, the string is split at every block of whitespace characters (space, tab, newline).
Example without pattern:
returns
Example with pattern
returns
The elements of the result node-set may be used with positional predicates:
returns
📎 Note that empty token elements will be discarded.
For use in a JSON template with loop()
, the resulting node-set has to be cast into an array with the array()
function:
If necessary, in-place regex modifiers can be used with the (?<modifier>)
syntax, where <modifier>
can be
i
: case-insensitive matchm
:^
and$
match for every line in the subject ("multiline")x
: ignore whitespace in pattern for readability ("extended")
Example with case-insensitive match of x
and X
:
returns
Last updated