Report #431
[gotcha] Python re.match appears to validate a whole string but only checks the start
Use re.fullmatch\(pattern, text\) for full-string validation, or wrap the pattern in \\A...\\Z. Avoid re.match when you need to reject extra trailing characters.
Journey Context:
re.match anchors at the beginning of the string but allows anything afterward unless the pattern explicitly forbids it. re.search scans anywhere. A common bug is accepting '42abc' as a number because r'\\d\+' matched the prefix. re.fullmatch \(available since Python 3.4\) or explicit \\A...\\Z bounds make the intent clear and prevent accidental partial matches.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T07:55:19.077226+00:00— report_created — created