Bracketing Expressions
You can use quoted parentheses, \( and \), to bracket a regular expression. The string that the bracketed regular expression matches can be recalled, as explained in “Quoted Digit,” following. A regular expression does not attempt to match quoted parentheses. Thus a regular expression enclosed within quoted parentheses matches what the same regular expression without the parentheses would match. The expression /\(rexp\)/ matches what /rexp/ would match, and /a\(b*\)c/ matches what /ab*c/ would match.
You can nest quoted parentheses. The bracketed expressions are identified only by the opening \( , so there is no ambiguity in identifying them. The expression /\([a–z]\([A–Z]*\)x\)/ consists of two bracketed expressions, one ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access