How can I use capturing groups inside lookahead assertion?
This code:
say "ab" ~~ m/(a) <?before (b) > /;
returns:
「a」
0 => 「a」
But I was expecting to also capture 'b'.
Is there a way to do so?
I don't want to leave 'b' outside of the lookahead because I don't want 'b' to be part of the match.
Is there a way to capture 'b' but still leave it outside of the match?
NOTE:
I tried to use Raku's capture markers, as in:
say "ab" ~~ m/<((a))> (b) /;
「a」
0 => 「a」
1 => 「b」
But this does not seem to work as I expect because even if 'b' is left ouside the match, the regex has processed 'b'. And I don't want to be processed too.
For example:
say 'abab' ~~ m:g/(a)<?before b>|b/;
(「a」
0 => 「a」
「b」
「a」
0 => 「a」
「b」)
# Four matches (what I want)
say 'abab' ~~ m:g/<((a))>b|b/;
(「a」
0 => 「a」
「a」
0 => 「a」)
# Two matches