-
Notifications
You must be signed in to change notification settings - Fork 560
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
split() with "branch reset (?|...)" works like "not capturing (?:...)" #22912
Comments
Also occurs in 5.36.0, have not had time to look further. Output from |
This might be behaving as documented but perhaps with a couple of behaviours in play at the same time? From split: Thus, when assigning to a list, if LIMIT is omitted (or zero), then LIMIT is treated as though it were one larger than the number of variables in the list and If the PATTERN contains capturing groups, then for each separator, an additional field is produced for each substring captured by a group (in the order in which the groups are specified, as per backreferences); if any group does not match, then it captures the undef value instead of a substring. |
Or not, I see now that you wouldn't expect to see trailing undefs in either case. |
This might be I don't know if branch reset should be taken into account when counting capture groups for |
Since I myself have never used From
From
From
I tested the OP's program with various perls built by perlbrew and observed a change in behavior between perl-5.36 and perl-5.38. I therefore bisected with this program (on linux unthreaded):
The result pointed to fe5492d (v5.37.7-120-gfe5492d916) as the point where behavior changed:
@demerphq, can you take a look? Thanks. |
Description
Regex "branch reset" pattern
(?|...)
is working like "not capturing" pattern(?:...)
if used insplit()
function:Output:
Steps to Reproduce
perl -E 'sub dd { say "(" . join(", ", map {defined ? qq{"$_"} : "undef"} @_) . ")" } dd(split(/\b(\w+)=(?|(\w+),(\d+)|(\d+);(\w+))\b/, "aa=AA,123 bb=123;dd"));'
Expected behavior
Output not containing undef:
Perl configuration
5.41.8 @61978476912ee303cc78e7bf09602a4b38f3d75e
The text was updated successfully, but these errors were encountered: