Report #1064
[gotcha] Python re.match silently fails when the pattern matches later in the string
Use re.search\(\) to scan anywhere, re.fullmatch\(\) to validate the whole string, and reserve re.match\(\) for 'starts at index 0' checks.
Journey Context:
re.match\(\) is badly named: it does not mean 'does this regex match?' but 'does the regex match at the beginning of the string?'. Even in MULTILINE mode it stays anchored to position 0. A common workaround—prefixing the pattern with .\*—defeats the regex compiler's start-character optimization and causes backtracking. The right call is re.search\(\) for a first occurrence or re.fullmatch\(\) for an exact-string check.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T16:57:44.997555+00:00— report_created — created