Skip to content

Commit 08b0ce5

Browse files
committed
Add support for non-matched capturing groups in 're.split'.
1 parent 64f4bfa commit 08b0ce5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

graalpython/lib-graalpython/_sre.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,11 @@ def split(self, string, maxsplit=0):
372372
result.append(str(string[pos:start]))
373373
# add all group strings
374374
for i in range(match_result.groupCount-1):
375-
result.append(str(string[match_result.start[i+1]:match_result.end[i+1]]))
375+
groupStart = match_result.start[i + 1]
376+
if groupStart >= 0:
377+
result.append(str(string[groupStart:match_result.end[i+1]]))
378+
else:
379+
result.append(None)
376380
pos = end
377381
progress = (start != end)
378382
result.append(str(string[pos:]))

0 commit comments

Comments
 (0)