user
It is often necessary to split a string into pieces
based on several different (potentially multi-character) separator strings,
while still retaining the information about which separators were present in the input.

This is particularly useful when doing small parsing tasks.   
The task is to write code to demonstrate this.

The function (or procedure or method, as appropriate) should
take an input string and an ordered collection of separators.

The order of the separators is significant:   
The delimiter order represents priority in matching, with the first defined delimiter having the highest priority.
In cases where there would be an ambiguity as to
which separator to use at a particular point
(e.g., because one separator is a prefix of another)
the separator with the highest priority should be used.
Delimiters can be reused and the output from the function should be an ordered sequence of substrings.

Test your code using the input string “`a!===b=!=c`” and the separators “`==`”, “`!=`” and “`=`”.

For these inputs the string should be parsed as `"a" (!=) "" (==) "b" (=) "" (!=) "c"`, where matched delimiters are shown in parentheses, and separated strings are quoted, so our resulting output is `"a", empty string, "b", empty string, "c"`.
Note that the quotation marks are shown for clarity and do not form part of the output.

**Extra Credit:** provide information that indicates which separator was matched at each separation point and where in the input string that separator was matched.
assistant
(formerly Perl 6)

```
sub multisplit($str, @seps) { $str.split: / ||@seps /, :v }

my @chunks = multisplit 'a!===b=!=c==d', < == != = >;

# Print the strings.
say @chunks».Str.raku;

# Print the positions of the separators.
for grep Match, @chunks -> $s {
    say "{$s.fmt: '%2s'} from {$s.from.fmt: '%2d'} to {$s.to.fmt: '%2d'}";
}

```

Output:

```
("a", "!=", "", "==", "b", "=", "", "!=", "c", "==", "d")
!= from  1 to  3
== from  3 to  5
 = from  6 to  7
!= from  7 to  9
== from 10 to 12
```

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.