Multisplit
Output:
Using the array @seps
in a pattern automatically does alternation. By default this would do longest-term matching (that is, |
semantics), but we can force it to do left-to-right matching by embedding the array in a short-circuit alternation (that is, ||
semantics). As it happens, with the task's specified list of separators, it doesn't make any difference.
Raku automatically returns Match objects that will stringify to the matched pattern, but can also be interrogated for their match positions, as illustrated above by post-processing the results two different ways.
Last updated