extmod/modure: Set subject begin_line so ^ doesn't match interior.

Fixes issue #8402.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2022-03-10 11:51:42 +11:00
parent adfd57c5fe
commit 63f0e700f4
3 changed files with 17 additions and 3 deletions

View File

@@ -31,3 +31,13 @@ print(s)
r = re.compile(b"x")
s = r.split(b"fooxbar")
print(s)
# using ^
r = re.compile("^ab")
s = r.split("abababcabab")
print(s)
# using ^ with |
r = re.compile("^ab|cab")
s = r.split("abababcabab")
print(s)

View File

@@ -75,3 +75,7 @@ except TypeError:
# Include \ in the sub replacement
print(re.sub("b", "\\\\b", "abc"))
# Using ^, make sure it doesn't repeatedly match
print(re.sub("^ab", "*", "abababcabab"))
print(re.sub("^ab|cab", "*", "abababcabab"))