Report #395
[gotcha] Python re.sub interprets \\10 as group 10, not group 1 followed by '0'
Use \\g<1>0 when you need a backreference followed by a literal digit. Use \\g for named groups. Prefer callable replacements for complex substitution logic.
Journey Context:
In replacement strings, \\1 through \\99 are parsed greedily as group references. If you have fewer than 10 groups, \\10 is still read as a reference to group 10 \(which is empty\) rather than group 1 plus '0'. The docs call out \\g<2>0 as the unambiguous form. This bites people building generated filenames, IDs, or templates where a captured number is followed by digits. A callback avoids the escaping problem entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T06:44:42.261992+00:00— report_created — created