Group pieces of a regex for readability or PCRE2 replacements.
Section: Regex basics
Use capture groups in patterns
bash
bash
rg '(GET|POST|PUT|DELETE) /api/' server.logExplanation
Even when not replacing, capture groups make complex patterns easier to reason about.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Regex basics
Escape regex metacharacters
Search for a literal dot while staying in regex mode.
Use Unicode-aware classes
Search for letters with Unicode-aware semantics.