Hi Marc! Is it just even/odd elements that you want to separate out? If so, maybe .grep() is your friend here:
> my $string0 = q!""''(){}[]! ""''(){}[] > $string0.comb[(0..*-1).grep(* %% 2)].say; (" ' ( { [) > $string0.comb[(0..*-1).grep(* % 2)].say; (" ' ) } ]) It sounds like you have some interest in 'pairing' the results, in which case this works (using .pairs()): > .say for [Z] $string0.comb[(0..*-1).grep(* %% 2)], $string0.comb[(0..*-1).grep(* % 2)]; (" ") (' ') (( )) ({ }) ([ ]) > .pairs.say for [Z] $string0.comb[(0..*-1).grep(* %% 2)], $string0.comb[(0..*-1).grep(* % 2)]; (0 => " 1 => ") (0 => ' 1 => ') (0 => ( 1 => )) (0 => { 1 => }) (0 => [ 1 => ]) > > $*VM moar (2021.06) HTH, Bill. On Sun, Aug 22, 2021 at 6:24 AM Marc Chantreux <e...@phear.org> wrote: > hello William, > > > your string, or whether-or-not some might be nested within each other. > You > > show a lone ampersand ("&") at the beginning of your example, but other > > strings may not be so simple. > > really sorry about this artefact from previous attempts :( > > > > $string.comb(/ ( <:Ps> ~ <:Pe> .?) /, :global).raku.say > > ("()", "\{}", "[]").Seq > > those regexes i can't read for the moment is a good excuse to learn more > about raku. i'll read them later and come back here if i have questions. > > thanks and regards. > marc >