I work with Czech accented text in Python 3.4.
Calling re.sub() to perform substitution by regex on an accented sentence works well, but using a regex compiled with
The last argument in the compile is flags, if you actually use flags=flags in the re.sub you will see the same behaviour:
compiled = re.compile(pattern, flags)
print(compiled)
text = 'Poplatníkem daně z pozemků je vlastník pozemku'
mark = r'**\1**' # wrap 1st matching group in double stars
r = re.sub(pattern, mark, text, flags=flags)
The fourth arg to re.sub is count so that is why you see the difference.
re.sub(pattern, repl, string, count=0, flags=0)
re.compile(pattern, flags=0)