Sean,
To follow up on what Brian said, you can also do the same thing
on a single line with named captures
https://docs.raku.org/language/regexes#Named_captures
(This often isn't as good as Brian's method, since breaking things
up as Brian showed often helps readability. But it can be a good
option if you're trying to keep something concise.)
Using that syntax, your example goes from
S:g[(x)|(y)] = $0 ?? x-replacement !! y-replacement
to
S:g[$<x>=[x]|y] = $<x> ?? x-replacement !! y-replacement
which is pretty similar.
I hope that helps!
Best,
Daniel
--
Daniel Sockwell / codesections
Website: www.codesections.com