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
bug of regex lookaround assertions? #16894
Comments
From malincns@163.comCreated by malincns@163.comThis report is about capture group. string : "abab" print defined($1)?"\"$1\"":"undef",", ",defined($2)?"\"$2\"":"undef", if Output: Excepted output: Some engines output: Perl 5.28.1 "b", "a" [1] seems this bug: Another doubtful case: string : "ab" print defined($1)?"\"$1\"":"undef",", ",defined($2)?"\"$2\"":"undef", if Output: Except output: Perl Info
|
From @jkeenanOn Mon, 18 Mar 2019 01:19:11 GMT, malincns@163.com wrote:
In each of these two cases, can you explain -- in your own words, and without reference to any other language's regex engines -- why you have come to the expectations you have? Thank you very much. -- |
The RT System itself - Status changed from 'new' to 'open' |
From malincns@163.com在 19-3-20 21:14, James E Keenan via RT 写道:
Please see these two cases: 1, print defined($1)?"\"$1\"":"undef",", ",defined($2)?"\"$2\"":"undef", Output: undef, "b" /(a)c/ this pattern can't match, so $1 is undef. 2, print defined($1)?"\"$1\"":"undef",", ",defined($2)?"\"$2\"":"undef", Output: "a", "b" /(?=(a))b/ this pattern can't match too, but $1 is not undef, It seems a bit inconsistent. |
From @jkeenanOn Wed, 20 Mar 2019 14:08:07 GMT, malincns@163.com wrote:
I doubt there are bugs here, but understanding what is going on with respect to the interaction of positive-lookahead assertions and capture groups is very tricky. There are things I don't understand myself. To be able to consider different cases, I've written a subroutine to handle each combination of string and pattern which you have mentioned in your two posts so far. Please see attached program 133940-regex.pl. When I run it, I get this output: ##### Case: 2 Case: 3 Case: 4 Case: 5 Case: 6 ##### The things I myself don't understand are: * In Case 3, if the string matches the pattern, and if that pattern includes captures, how can any element in this list of captures be undefined? * In Case 6, why doesn't the string match the pattern? Can someone on list clarify? Thank you very much. -- |
From @jkeenan |
From @iabynOn Wed, Mar 20, 2019 at 08:49:21AM -0700, James E Keenan via RT wrote:
This looks to be a variant of [perl #133352] Ancient Regex Regression -- |
This has been fixed by commit acababb
|
Migrated from rt.perl.org#133940 (status was 'open')
Searchable as RT133940$
The text was updated successfully, but these errors were encountered: