This program
say "zipi zape" ~~ /(\w)\w» \s+ \w+({$0})/;
returns
「pi zape」
0 => 「p」
1 => 「」
which I interpret as the backreference to the first match being matched to a zero-width match? Maybe because it's matched to $0, which is itemized to '' outside the regex? How could I use these backreferences, and capture at the same time the match? Note: this related to this documentation issue, which requires clarification of the use of backreferences.
According to the documentation:
If you need to refer to a capture from within another capture, store it in a variable first
So you could use:
say "zipi zape" ~~ /(\w){} :my $c = $0; \w » \s+ \w+($c)/;
Output:
「pi zap」
0 => 「p」
1 => 「p」
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With