I recently stumbled upon this:
PCRE Regex Syntax – Recursive Patterns
It appears to open up possibilities to “match” html tags, which regular expresisons were not good at. Can this experimental feature, in any way, be used to parse fragments of HTML? or the document, if possible?
It is highly recommended not to use regex for HTML parsing, recursion or no. People often use it because when you have a hammer, the world looks like a nail. The correct tool would be something more like PHP’s DOMDocument class, which is fully designed for solving exactly this type of problem.
http://php.net/manual/en/class.domdocument.php