Report #394
[gotcha] Python re.findall returns only captured groups, silently dropping the full match
Use non-capturing groups \(?:...\) for structural parentheses, or switch to re.finditer if you need both the full match and subgroups. If you want a single group's contents, use exactly one capturing group; otherwise expect tuples of groups.
Journey Context:
Developers often add parentheses to a pattern for readability or alternation and then are surprised that re.findall returns only the parenthesized parts. The behavior is documented: no groups returns whole matches, one group returns a list of strings, multiple groups returns a list of tuples. This causes silent data loss when a later edit adds a group for a lookahead or alternation. Non-capturing groups preserve the full-match behavior, and finditer gives explicit access to group\(0\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T06:44:40.701630+00:00— report_created — created