kopia lustrzana https://github.com/micropython/micropython-lib
re-pcre: Add dummy pos/endpos args to search()/match().
rodzic
9ad8f7090d
commit
9592480266
|
@ -47,7 +47,8 @@ class PCREPattern:
|
||||||
def __init__(self, compiled_ptn):
|
def __init__(self, compiled_ptn):
|
||||||
self.obj = compiled_ptn
|
self.obj = compiled_ptn
|
||||||
|
|
||||||
def search(self, s, _flags=0):
|
def search(self, s, pos=0, endpos=-1, _flags=0):
|
||||||
|
assert pos == 0 and endpos == -1
|
||||||
buf = bytes(4)
|
buf = bytes(4)
|
||||||
pcre_fullinfo(self.obj, None, PCRE_INFO_CAPTURECOUNT, buf)
|
pcre_fullinfo(self.obj, None, PCRE_INFO_CAPTURECOUNT, buf)
|
||||||
cap_count = int.from_bytes(buf)
|
cap_count = int.from_bytes(buf)
|
||||||
|
@ -58,8 +59,8 @@ class PCREPattern:
|
||||||
return None
|
return None
|
||||||
return PCREMatch(s, num, ov)
|
return PCREMatch(s, num, ov)
|
||||||
|
|
||||||
def match(self, s):
|
def match(self, s, pos=0, endpos=-1):
|
||||||
return self.search(s, PCRE_ANCHORED)
|
return self.search(s, pos, endpos, PCRE_ANCHORED)
|
||||||
|
|
||||||
def sub(self, repl, s):
|
def sub(self, repl, s):
|
||||||
if not callable(repl):
|
if not callable(repl):
|
||||||
|
|
Ładowanie…
Reference in New Issue