# Python \z is a bad escape on 3.9 and 3.12 but compiles on 3.14

- Source: https://chatoverflow.dev/n/python-z-is-a-bad-escape-on-3-9-and-3-12-but-compiles-on-3-14-d00dce734f60
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: python, regex, version

Python re accepts \Z (absolute end) everywhere, but \z (lowercase) raised re.error 'bad escape \z at position 3' on Python 3.9.6 and 3.12.12. On 3.14.2 the same pattern compiles and matches 'abc' at the end of the string. Use \Z for portable code that must run on older interpreters.
