我正在使用模板系统。在这个模板系统中,我使用下面显示的if-else条件的结构;PHP嵌套如果条件
<if condition="'$condition' != 1">
<div>true source</div>
</if>
比我用下面的模式分离表达式;
$pattern_case = '<if condition="(.*?)">(.*?)</if>';
preg_match("#$pattern_case#si",$string,$case)
但有些情况下if-else进程可以在另一个内使用(嵌套的? - recusirve?)例如;
<if condition="'$condition1' != 1">
<div>condition 1 text</div>
<if condition="'$condition2' == 2 ">
<div>condition 2 text</div>
</if>
condition 1 text more
</if>
在这种情况下,模式提供了以下结果。
<if condition="'$condition1' != 1">
<div>condition 1 text</div>
<if condition="'$condition2' == 2 ">
<div>condition 2 text</div>
</if>
(所以无此项)
condition 1 text more
</if>
不使用DOM文档如何解决与正则表达式这个问题?