You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
353 B
17 lines
353 B
7 years ago
|
# test re.sub with unmatched groups, behaviour changed in CPython 3.5
|
||
|
|
||
|
try:
|
||
2 years ago
|
import re
|
||
7 years ago
|
except ImportError:
|
||
2 years ago
|
print("SKIP")
|
||
|
raise SystemExit
|
||
7 years ago
|
|
||
|
try:
|
||
|
re.sub
|
||
|
except AttributeError:
|
||
5 years ago
|
print("SKIP")
|
||
7 years ago
|
raise SystemExit
|
||
|
|
||
|
# first group matches, second optional group doesn't so is replaced with a blank
|
||
5 years ago
|
print(re.sub(r"(a)(b)?", r"\2-\1", "1a2"))
|