Greg Donald : Raku split delimiter can be a list Page

Raku split delimiter can be a list

Raku's string split routine accepts a scalar as well as a list for its delimiter.

my Str $str = 'This string,has commas,and spaces';
my @delimiters of Str = [' ', ','];
my @array of Str = $str.split(@delimiters);

say @array.perl;


Which gives you:

Array[Str].new("This", "string", "has", "commas", "and", "spaces")


Other languages might require you to write a regular expression if you need to split a string on multiple delimiters at the same time.

raku (16)