Regex Cheat Sheet/Branch reset group

Reset group numbers per alternation branch.

Section: Groups and Alternation

Branch reset group

regex
regex
(?|(Mr|Ms)\.?\s+(\w+)|(Dr)\.?\s+(\w+))
Explanation

PCRE feature useful when alternate branches should expose the same capture numbers.

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 Groups and Alternation
Capturing group
Capture a submatch for reuse or extraction.
OpenIn sheetregexsame section
Non-capturing group
Group without creating a numbered capture.
OpenIn sheetregexsame section
Nested groups
Combine multiple grouped pieces.
OpenIn sheetregexsame section
Optional group
Make an entire grouped piece optional.
OpenIn sheetregexsame section
Alternation
Match one branch or another.
OpenIn sheetregexsame section
Quoted literal block
Treat a whole block as literal text.
OpenIn sheetregex1 tag match