Hi Brian, I would think this would become pretty easy. Consider:
sub MAIN ( $replacement, :$x, :$y ) { my regex x {<{ $x }> } my regex y { <{$y}> } S:g! <x> ! <{ $replacemement }> ! if $x; S:g! <y> ! <{ $replacement }> ! if $y } Is this what you are looking for or did I miss something? > > > > ... > > > "y" ~~ /(x)|(y)/ I would probably take > advantage of the composability of Raku regexes, and do something like my > regex x { x } my regex y { y } and then use / | / and check for $ or $ e.g. > this becomes S:g[|] = $ ?? x-replacement !! y-replacement