fix start and end positions of match
the `match.pos` and `match.endpos` are not the start and end of the matched group but the start and end arguments passed to the `re.match()` method. use `match.start()` and `match.end()` to find the beginning and the end of the matched group. see https://docs.python.org/3/library/re.html#match-objects
This commit is contained in:
parent
bf4c062d43
commit
2d1560e92a
@ -284,8 +284,8 @@ class RegexArgument(Argument):
|
|||||||
val = val.split(" ")[0]
|
val = val.split(" ")[0]
|
||||||
match = self.regex.match(val)
|
match = self.regex.match(val)
|
||||||
if match:
|
if match:
|
||||||
return (orig_val[:match.pos] + orig_val[match.endpos:],
|
return (orig_val[:match.start()] + orig_val[match.end():],
|
||||||
match.groups() or val[match.pos:match.endpos])
|
match.groups() or val[match.start():match.end()])
|
||||||
return orig_val, None
|
return orig_val, None
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user