Skip to content

Commit 4a215d6

Browse files
committed
Add all matched groups to split array.
1 parent 79ecf26 commit 4a215d6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

graalpython/lib-graalpython/_sre.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ def sub(self, repl, string, count=0):
354354
except BaseException:
355355
return self.__compile_cpython_sre().sub(repl, string, count)
356356

357+
357358
def split(self, string, maxsplit=0):
358359
n = 0
359360
try:
@@ -368,10 +369,13 @@ def split(self, string, maxsplit=0):
368369
n += 1
369370
start = match_result.start[0]
370371
end = match_result.end[0]
371-
result.append(string[pos:start])
372+
result.append(str(string[pos:start]))
373+
# add all group strings
374+
for i in range(match_result.groupCount-1):
375+
result.append(str(string[match_result.start[i+1]:match_result.end[i+1]]))
372376
pos = end
373377
progress = (start != end)
374-
result.append(string[pos:])
378+
result.append(str(string[pos:]))
375379
return result
376380
except BaseException:
377381
return self.__compile_cpython_sre().split(string, maxsplit)

0 commit comments

Comments
 (0)