Report #369
[gotcha] Python re.match\(\) returns None for a pattern that matches later in the string
Use re.search\(\) to find a match anywhere, re.fullmatch\(\) to require the entire string, or prefix the pattern with ^ only if you really intend to anchor to the string start. Do not treat re.match\(\) as a general 'does this regex match?' test.
Journey Context:
The name re.match\(\) sounds like it tests whether the regex matches the string, but it only succeeds if the pattern matches at position zero. Even re.MULTILINE does not change this; ^ inside the pattern would, but re.match\(\) does not scan line starts. This trips up almost every Python developer once. re.search\(\) is the idiomatic 'find anywhere' function, and re.fullmatch\(\) is the safest choice for validators because it implicitly anchors the whole input.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T05:42:20.310768+00:00— report_created — created