I'm looking to improve the below regex as I now would like to match nested tags as well:
'%{if:\s*"\'([^\']*)\' == \'([^\']*)\'"}((?:(?!{else}|{/endif}).)*){else}((?:(?!{/endif}).)*){/endif}%sei'
Which basically matches:
{if: "'x' == 'y'"}
a
{else}
b
{/endif}
or
{if: "'x' == 'y'"}
c
{/endif}
However, I would like this to be recursive in some sort of way, so nested statements could also be matched without breaking anything (at the moment it breaks if a nested statement is added).
There would also be a similar expression with !=
.
I've found this http://www.devnetwork.net/viewtopic.php?f=38&t=102670&sid=02b7c691a2be894336c694700f8f911a#p551340 which matches <div>
tags, though a bit unsure how to adapt it to suit my regex...