Cheatsheet Pages / Regex Cheatsheet
How to capture parts of a match — (...) groups
You do not just want a match: you want the pieces — area code here, number there — numbered from 1, left to right.
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.
(\d{3})-(\d{4})
# group 1 = area code, group 2 = number
(ha)+
# "ha", "haha", "hahaha" — quantifier applies to the group
