I'm playing around trying to make a small template class and i run into a little trouble
I'm trying to match this nested loop
<ul>
{each $nestedArr}
<li>{$group}</li>
<ul>
{each $users}
<li>{$name}</li>
{/each}
</ul>
{/each}
</ul>
What i got so far is this
preg_match('/{each \$nestedArr}(?:(?R)|(.*?)){\/each}/is', $this->buffer, $match);
But the problem is that it stops at the first closing {/each}
Any tips on how i can fix that ?
For conviniance i also added on regex101
strposfor finding matching{}braces, for example) and recursive function calls for processing text betweeneachblocks. Regular expressions are powerful, but for solving simple problems you usually only need simple solutions.