June 2025
Beginner to intermediate
473 pages
13h 30m
English
You can use () to create a group within an expression. Then, within the expression, you can use | to formulate alternative patterns, one of which optionally applies. In addition, you can access the contents of recognized groups using \1, \2, etc. or using $1, $2, etc., depending on the regex dialect. Various applications exist for this feature, such as detecting repetitions or performing search-and-replace operations.
The following three examples illustrate the use of groups. However, I must use + and {1,2} to anticipate the next section, which is about quantifiers. + means that the preceding expression must occur once or more often. {1,2} means that the preceding expression must occur exactly once or twice.
Read now
Unlock full access