Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Most aspects of the preg engine’s flavor are covered as general topics in Chapter 3, but the flavor does offer something new in its interesting way of matching nested constructs: recursive expressions.
The sequence ?(?R)? means “recursively apply the entire expression at this point,” while ?(?num)? sequence means “recursively apply the sequence within the numbered set of capturing parentheses at this point.” The named-capture version of the latter uses a ?(?P>name)? notation.
The next few sections show some common uses for recursion. Recursion also plays a central role in the extended “tagged data” example, which starts on page 481.