1# test re.sub with unmatched groups, behaviour changed in CPython 3.5 2 3try: 4 import ure as re 5except ImportError: 6 try: 7 import re 8 except ImportError: 9 print("SKIP") 10 raise SystemExit 11 12try: 13 re.sub 14except AttributeError: 15 print("SKIP") 16 raise SystemExit 17 18# first group matches, second optional group doesn't so is replaced with a blank 19print(re.sub(r"(a)(b)?", r"\2-\1", "1a2")) 20