Possible Duplicate:
RegEx match open tags except XHTML self-contained tags
Hi to all!
Could you please explain to me a little about a recursive regular expression in PHP PCRE? So, for example I have general nested html:
<div id="first">
<b>some text</b>
<div id="second">
<div id="third">
...
</div>
</div>
</div>
and want to build an array of divs. According to docs, I can call to regex in two ways: (?R) or (?n). In last example n references to appopriate subpattern. So, when I call (?R) does it start to search string with a whole expression from the very beginning and "forgets" about first match? Logically, I can describe a pattern to above string like this: 'search div, which will contain zero or more attributes, and which may contain nested divs. Stop if there are no more nested divs inside."
I have tried with it a little, but often got an error: 'compilation error, regex can loop indefinitely."
I would like to understand the theory how recursions work in regular expression.