@@ -54,14 +54,14 @@ def __init__(self, pattern_input, isMatch, groupCount, start, end):
54
54
self .input = pattern_input
55
55
self .isMatch = isMatch
56
56
self .groupCount = groupCount
57
- self .start = start
58
- self .end = end
57
+ self ._start = start
58
+ self ._end = end
59
59
60
60
def getStart (self , grpidx ):
61
- return self .start [grpidx ]
61
+ return self ._start [grpidx ]
62
62
63
63
def getEnd (self , grpidx ):
64
- return self .end [grpidx ]
64
+ return self ._end [grpidx ]
65
65
66
66
67
67
def _str_to_bytes (arg ):
@@ -158,7 +158,7 @@ def __init__(self, pattern, pos, endpos, result, input_str, compiled_regex):
158
158
self .input_str = input_str
159
159
160
160
def end (self , groupnum = 0 ):
161
- return self .result .end [ groupnum ]
161
+ return self .result .getEnd ( groupnum )
162
162
163
163
def group (self , * args ):
164
164
if not args :
@@ -185,11 +185,11 @@ def __groupidx__(self, idx):
185
185
186
186
def __group__ (self , idx ):
187
187
idxarg = self .__groupidx__ (idx )
188
- start = self .result .start [ idxarg ]
188
+ start = self .result .getStart ( idxarg )
189
189
if start < 0 :
190
190
return None
191
191
else :
192
- return self .input_str [start :self .result .end [ idxarg ] ]
192
+ return self .input_str [start :self .result .getEnd ( idxarg ) ]
193
193
194
194
def groupdict (self , default = None ):
195
195
d = {}
@@ -202,11 +202,11 @@ def groupdict(self, default=None):
202
202
203
203
def span (self , groupnum = 0 ):
204
204
idxarg = self .__groupidx__ (groupnum )
205
- return (self .result .start [ idxarg ] , self .result .end [ idxarg ] )
205
+ return (self .result .getStart ( idxarg ) , self .result .getEnd ( idxarg ) )
206
206
207
207
def start (self , groupnum = 0 ):
208
208
idxarg = self .__groupidx__ (groupnum )
209
- return self .result .start [ idxarg ]
209
+ return self .result .getStart ( idxarg )
210
210
211
211
@property
212
212
def string (self ):
@@ -218,7 +218,7 @@ def lastgroup(self):
218
218
219
219
@property
220
220
def lastindex (self ):
221
- return self .result .end [ 0 ]
221
+ return self .result .getEnd ( 0 )
222
222
223
223
def __repr__ (self ):
224
224
return "<re.Match object; span=%r, match=%r>" % (self .span (), self .group ())
@@ -341,8 +341,8 @@ def finditer(self, string, pos=0, endpos=-1):
341
341
break
342
342
else :
343
343
yield SRE_Match (self , pos , endpos , result , string , compiled_regex )
344
- no_progress = (result .start [ 0 ] == result .end [ 0 ] )
345
- pos = result .end [ 0 ] + no_progress
344
+ no_progress = (result .getStart ( 0 ) == result .getEnd ( 0 ) )
345
+ pos = result .getEnd ( 0 ) + no_progress
346
346
return
347
347
348
348
def findall (self , string , pos = 0 , endpos = - 1 ):
@@ -358,21 +358,21 @@ def findall(self, string, pos=0, endpos=-1):
358
358
if not result .isMatch :
359
359
break
360
360
elif result .groupCount == 1 :
361
- matchlist .append (self .__sanitize_out_type (string [result .start [ 0 ] :result .end [ 0 ] ]))
361
+ matchlist .append (self .__sanitize_out_type (string [result .getStart ( 0 ) :result .getEnd ( 0 ) ]))
362
362
elif result .groupCount == 2 :
363
- matchlist .append (self .__sanitize_out_type (string [result .start [ 1 ] :result .end [ 1 ] ]))
363
+ matchlist .append (self .__sanitize_out_type (string [result .getStart ( 1 ) :result .getEnd ( 1 ) ]))
364
364
else :
365
365
matchlist .append (tuple (map (self .__sanitize_out_type , SRE_Match (self , pos , endpos , result , string , compiled_regex ).groups ())))
366
- no_progress = (result .start [ 0 ] == result .end [ 0 ] )
367
- pos = result .end [ 0 ] + no_progress
366
+ no_progress = (result .getStart ( 0 ) == result .getEnd ( 0 ) )
367
+ pos = result .getEnd ( 0 ) + no_progress
368
368
return matchlist
369
369
370
370
def __replace_groups (self , repl , string , match_result , pattern ):
371
371
def group (match_result , group_nr , string ):
372
372
if group_nr >= match_result .groupCount :
373
373
return None
374
- group_start = match_result .start [ group_nr ]
375
- group_end = match_result .end [ group_nr ]
374
+ group_start = match_result .getStart ( group_nr )
375
+ group_end = match_result .getEnd ( group_nr )
376
376
return string [group_start :group_end ]
377
377
378
378
n = len (repl )
@@ -442,8 +442,8 @@ def sub(self, repl, string, count=0):
442
442
if not match_result .isMatch :
443
443
break
444
444
n += 1
445
- start = match_result .start [ 0 ]
446
- end = match_result .end [ 0 ]
445
+ start = match_result .getStart ( 0 )
446
+ end = match_result .getEnd ( 0 )
447
447
result .append (string [pos :start ])
448
448
if is_string_rep :
449
449
result .append (self .__replace_groups (repl , string , match_result , pattern ))
@@ -473,14 +473,14 @@ def split(self, string, maxsplit=0):
473
473
if not match_result .isMatch :
474
474
break
475
475
n += 1
476
- start = match_result .start [ 0 ]
477
- end = match_result .end [ 0 ]
476
+ start = match_result .getStart ( 0 )
477
+ end = match_result .getEnd ( 0 )
478
478
result .append (self .__sanitize_out_type (string [collect_pos :start ]))
479
479
# add all group strings
480
480
for i in range (1 , match_result .groupCount ):
481
- groupStart = match_result .start [ i ]
481
+ groupStart = match_result .getStart ( i )
482
482
if groupStart >= 0 :
483
- result .append (self .__sanitize_out_type (string [groupStart :match_result .end [ i ] ]))
483
+ result .append (self .__sanitize_out_type (string [groupStart :match_result .getEnd ( i ) ]))
484
484
else :
485
485
result .append (None )
486
486
collect_pos = end
0 commit comments