Creating Groups and Alternation
In regular expressions, parentheses () serve two primary functions: grouping sub-patterns together and capturing the matched text for later use.
Creating Groups for Extraction
By placing parentheses around a part of your regex pattern, you create a "capture group". This allows you to isolate and extract specific segments of the matched string, which is essential for parsing structured text like logs, phone numbers, or emails.