Report #1862
[gotcha] ^ and $ matching every line instead of the whole string
Use \\A and \\Z \(or \\z\) for absolute string boundaries. Use ^ and $ only when you explicitly want line boundaries with the re.MULTILINE flag. When validating an entire input, always anchor with \\A...\\Z.
Journey Context:
With re.MULTILINE, ^ and $ match after and before newlines, so ^\\d\+$ validates every line individually. Many developers write validation patterns like ^\\w\+$ thinking they constrain the whole string, but with multiline mode they let multi-line payloads through. Without multiline ^ and $ still match string boundaries but not line boundaries. The safe explicit anchors are \\A and \\Z or \\z.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T08:51:47.717241+00:00— report_created — created