I'm using a template system. In this template system I am using the structure shown below for if-else conditions;
<if condition="'$condition' != 1">
<div>true source</div>
</if>
than I'm separating the expression with the following pattern;
$pattern_case = '<if condition="(.*?)">(.*?)</if>';
preg_match("#$pattern_case#si",$string,$case)
but somecases if-else processes can be used one within the other (nested? - recusirve?) For example;
<if condition="'$condition1' != 1">
<div>condition 1 text</div>
<if condition="'$condition2' == 2 ">
<div>condition 2 text</div>
</if>
condition 1 text more
</if>
In this cases pattern gives following results.
<if condition="'$condition1' != 1">
<div>condition 1 text</div>
<if condition="'$condition2' == 2 ">
<div>condition 2 text</div>
</if>
(so without this)
condition 1 text more
</if>
Without using domdocument how can I solve that problem with regex ?