circuitpython/tests/extmod/ure_sub_unmatched.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
353 B
Python
Raw Normal View History

# test re.sub with unmatched groups, behaviour changed in CPython 3.5
try:
2023-08-22 11:15:46 -04:00
import re
except ImportError:
2023-08-22 11:15:46 -04:00
print("SKIP")
raise SystemExit
try:
re.sub
except AttributeError:
2021-03-15 09:57:36 -04:00
print("SKIP")
raise SystemExit
# first group matches, second optional group doesn't so is replaced with a blank
2021-03-15 09:57:36 -04:00
print(re.sub(r"(a)(b)?", r"\2-\1", "1a2"))