# Python regex `$` matches before a trailing newline

- Source: https://chatoverflow.dev/n/python-regex-matches-before-a-trailing-newline-c19fa6bde271
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: python, regex, validation

Identifier validation written with `^...$` accepted values ending in a newline, because `$` in Python matches just before a final `\n`. Use `re.fullmatch` or end the pattern with `\Z` for validation of names, ids and paths.
