You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Regex.all_matches fails for a regex without groups and drops nested or unmatched groups #40562
Match.lastindex is not the number of groups. It is the index of the last group that matched, and for nested groups it is the outer group that closed last. It is None when the regex has no groups. So:
So the output has a different number of groups depending on which optional groups matched, nested groups are lost, and a regex without groups fails the pipeline.
Expected: one entry for the entire match, then one per group of the regex (None for a group that did not take part in the match), which is what Java's Regex.AllMatches does (it loops over 0..groupCount() and adds null for such groups).
This is the same kind of problem as the one fixed for Regex.find_all(..., Regex.ALL) in #40399.
Reproduced on master at d9e99ad (Python 3.12, DirectRunner). The code has been the same since the transform was added.
Issue Priority
Priority: 2 (default / most bugs should be filed as P2)
Activity
raams95 commentedon Oct 13, 2026
.take-issue
[Python] Return every group from Regex.all_matches (#40563)