Skip to content

Commit ed76265

Browse files
committed
Use lastGroup exported from TRegex's RegexResult
1 parent 99d48d5 commit ed76265

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

graalpython/lib-graalpython/_sre.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,11 @@ def lastgroup(self):
275275

276276
@property
277277
def lastindex(self):
278-
lastindex = None
279-
for index in range(1, self.__compiled_regex.groupCount):
280-
if self.__result.getStart(index) >= 0:
281-
lastindex = index
282-
return lastindex
278+
lastindex = self.__result.lastGroup
279+
if lastindex == -1:
280+
return None
281+
else:
282+
return lastindex
283283

284284
def __repr__(self):
285285
return "<%s object; span=%r, match=%r>" % (type(self).__name__, self.span(), self.group())

0 commit comments

Comments
 (0)