Cheatsheet Pages / Regex Cheatsheet

How to name a capture group — (?<name>...)

Group $7 tells you nothing; a group named year explains itself.

Patterns use the syntax shared by PCRE / Python / JavaScript; engine differences are flagged in the cheatsheet where they matter. Test any pattern at regex101.com — and pick the matching engine.

(?<year>\d{4})-(?<month>\d{2})
# year="2026", month="10"

Good to know

Python also accepts (?P<name>...); JavaScript needs ES2018+.

Regex Cheatsheet one-page card — patterns that actually work
The full one-page card — Regex Cheatsheet. Get the complete cheatsheet on GitHub