The following table describes the grouping constructs. Grouping constructs allow you to capture groups of sub-expressions and to increase the efficiency of regular expressions with non-capturing look ahead and look behind modifiers.
Table B.7 | List of Grouping Constructs |
|
|
( )
|
Captures the matched substring if used in a find and replace operation.
|
(?=)
|
Zero-width positive look ahead assertion. Continues match only if the sub-expression matches at this position on the right. For example, (_?=\w) matches an underscore followed by a word character without matching the word character.
|
(?!)
|
Zero-width negative look ahead assertion. Continues match only if the sub-expression matches at this position on the right. For example, \b(?!un)\w+\b matches words that do not begin with un.
|
(?<=)
|
Zero-width positive look behind assertion. Continues match only if the sub-expression matches the position on the left. For example, (?<=19)99 matches instances of 99 that follow 19.
|
(?<!)
|
Zero width negative look behind assertion. Continues match only if the sub-expression does not match this position on the left.
|