diff options
| author | Damien George <damien@micropython.org> | 2022-03-10 11:51:42 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-03-16 12:21:00 +1100 |
| commit | 63f0e700f4e8927854ec1f70eeb114fa079632a3 (patch) | |
| tree | 5ca8cf57a6bf5e0fbdeb9624ece6a7723d29f416 /tests | |
| parent | adfd57c5fedec4e64c2e34cbea89aa6ecdb40a50 (diff) | |
extmod/modure: Set subject begin_line so ^ doesn't match interior.
Fixes issue #8402.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/extmod/ure_split.py | 10 | ||||
| -rw-r--r-- | tests/extmod/ure_sub.py | 4 |
2 files changed, 14 insertions, 0 deletions
diff --git a/tests/extmod/ure_split.py b/tests/extmod/ure_split.py index a8b9c1686..7e6ef3990 100644 --- a/tests/extmod/ure_split.py +++ b/tests/extmod/ure_split.py @@ -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) diff --git a/tests/extmod/ure_sub.py b/tests/extmod/ure_sub.py index ae6ad28d6..806c38957 100644 --- a/tests/extmod/ure_sub.py +++ b/tests/extmod/ure_sub.py @@ -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")) |
