Regular Expressions 101

Community Patterns

outer Parentheses

4

Regular Expression
PCRE (PHP <7.3)

/
(\((?:([^\(\)]*)|(?:(?2)(?1)(?2))*)\))
/

Description

Finds the outermost pair of parentheses. Compatible with any amount of nesting

Submitted by Jonas Gerneth - 10 years ago