How can I use capturing groups inside lookbehind assertions?
I tried to use the same formula as in this answer. But that does not seem to work with lookbehinds.
Conceptually, this is what I was trying to do.
say "133" ~~ m/ <?after $0+> (\d) $ /
I know this can be easily achieved without lookbehinds, but ignore that just for now :)
For this I tried with these options:
Use :var
syntax:
say "133" ~~ m/ <?after $look-behind+> (\d):my $look-behind; $ /;
# Variable '$look-behind' is not declared
Use code block
syntax defining the variable outside:
my $look-behind;
say "133" ~~ m/ <?after $look-behind+> (\d) {$look-behind=$0} $ /;
# False
It seems that the problem is that the lookbehind
is executed before the "code block/:my $var", and thus the variable is empty for the lookbehind tree.
Is there a way to use capturing groups inside lookbehinds?