Use parentheses to enclose a group of related search elements. Parentheses limit scope on alternation and create substrings to enhance searches with metacharacters. For example, use parentheses to group the expression (abc), then apply the range quantifier {3} to find instances of the string "abcabcabc".
Example 1: Use parentheses and a range quantifier to find instances of the string "abcabcabc".
(abc){3}
abcabcabc abcabcabcabc
abc abcabc
Example 2: Use parentheses to limit the scope of alternative matches on the words gray and grey.
gr(a|e)y
gray grey
gry graey
Example 3: Use parentheses and "|" to locate past correspondence in a mail-filtering program. This regex finds a "To:" or a "From:" line followed by a space and then either the word "Smith" or the word "Chan".
(To:|From:)(Smith|Chan)
To:Smith To:Chan From:Smith To:Smith, Chan To:Smithe From:Channel4News
To:smith To:All To:Schmidt