Version: v0.6.1 - Beta.  We welcome contributors & feedback.  THanks!

String.split

split($stringOrRegex, $limit = 0)

Description

Split into a list of substrings, on a string delimiter or regex pattern.

If $limit is positive, the List will contain a maximum $limit elements. The last element will contain the rest of the string.

'a, b, c'.split(', ');
//= ['a', 'b', 'c']

'a  b c '.split(R'\s+');
//= ['a', 'b', 'c', '']

'a,b,c,d,e'.split(',', 3);
//= ['a', 'b', 'cde']

See Also