New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
backreferences to quantified captures are inconsistent in rakudo #2404
Comments
From @moritz10:49 < moritz> rakudo: say 'aaaa' ~~ /(\w)+$0/; say $0 I think it is inconsistent that $0 in the regex only matches $0[*-1], I'm not sure what the desired behavior is. |
From @TimToadyMatching only the final match is not desirable, in my opinion. It should match the string traversed by all the matches in $0, including intervening separators, if any. The problem is that ~$0 has spaces interpolated, which will match only if the separators happen to be a single space, so there is now a $0.backref that returns the string actually traversed by the entire list of matches. Matching $0 as a backref should use that method. > p6 'my $abc = " a,b,c, "; $abc ~~ /(\w+ % ",")/; say $0.backref' BTW, matching just the final match can be accomplished with something like $($0[*-1]), I suspect. |
1 similar comment
From @TimToadyMatching only the final match is not desirable, in my opinion. It should match the string traversed by all the matches in $0, including intervening separators, if any. The problem is that ~$0 has spaces interpolated, which will match only if the separators happen to be a single space, so there is now a $0.backref that returns the string actually traversed by the entire list of matches. Matching $0 as a backref should use that method. > p6 'my $abc = " a,b,c, "; $abc ~~ /(\w+ % ",")/; say $0.backref' BTW, matching just the final match can be accomplished with something like $($0[*-1]), I suspect. |
From @jnthnOn Tue Apr 12 02:01:28 2011, moritz wrote:
The new behavior is that we take the latest contiguous sequence of captures and the backref is the string ranging from the .from of the first capture in that sequence to the .to of the last capture in that sequence. So now: $ perl6-m -e "say 'aaaa' ~~ /(\w)+$0/; say $0" Note the contiguous constraint is needed to fix this case while also not breaking cases like: "bookkeeper" ~~ m/(((\w)$0)+)/ Which should match "ookkee". Tests in S05-capture/dot.t. /jnthn |
The RT System itself - Status changed from 'new' to 'open' |
@jnthn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#88340 (status was 'resolved')
Searchable as RT88340$
The text was updated successfully, but these errors were encountered: