Parentheses are used in regular expressions in a couple different ways:
- Creating subexpressions to be treated as a single unit with the
?repetition characters or the
|alternation character that follows it.
- Defining subpatterns to be extracted from the target string.
- To be referenced later using reference characters (