Chapter 3. Grouping
Grouping is a powerful tool that allows you to perform operations such as:
Creating subexpressions to apply quantifiers. For instance, repeating a subexpression rather than a single character.
Limiting the scope of the alternation. Instead of alternating the whole expression, we can define exactly what has to be alternated.
Extracting information from the matched pattern. For example, extracting a date from lists of orders.
Using the extracted information again in the regex, which is probably the most useful property. One example would be to detect repeated words.
Throughout this chapter, we will explore groups, from the simplest to the most complex ones. We'll review some of the previous examples in order to bring clarity to how these operations work.