$s =~ s{ (?| $string \K ($curly_grp) | $string \[ \K ($curly_grps) (?= \]) ) } { $1 =~ tr{,}{|}r }xmsge;