I'm trying to use regex to parse a template I have. I want to find the _stop
tag for the _start
tag. I need to find the specific ones since there can be nested _stop
and _start
tags.
The regex I'm using is
/{(.*?)_start}.*{(\1_stop)}/s
and throwing that into a preg_match
And the template
<div data-role="collapsible-set" class="mfe_collapsibles" data-theme="c" data-inset="false">
{MakeAppointment_start}
<div id="appointmentHeading" data-action-id="appointmentNext" data-action-text="Next" data-a data-role="collapsible" data-collapsed="true" data-collapsed-icon="arrow-r" data-expanded-icon="arrow-d" data-iconpos="right">
<h3 class="collapsibleMainHeading">New {AppointmentTerm}</h3>
<p>
{AppointmentForm}
</p>
</div>
{MakeAppointment_stop}
{RegisterSection_start}
<div id="registerHeading" class="preRegistration" data-action-id="register" data-action-text="Register" data-role="collapsible" data-collapsed="true" data-collapsed-icon="arrow-r" data-expanded-icon="arrow-d" data-iconpos="right">
<h3 class="collapsibleMainHeading">Register</h3>
<p>
{RegisterForm}
</p>
</div>
{RegisterSection_stop}
<div data-role="collapsible" class="preRegistration" data-collapsed="true" data-collapsed-icon="arrow-r" data-expanded-icon="arrow-d" data-iconpos="right">
<h3 class="collapsibleMainHeading">Login</h3>
<p>
{LoginForm}
</p>
</div>
</div>
</div>
The results are
Array
(
[0] => {MakeAppointment_start}
<div id="appointmentHeading" data-action-id="appointmentNext" data-action-text="Next" data-a data-role="collapsible" data-collapsed="true" data-collapsed-icon="arrow-r" data-expanded-icon="arrow-d" data-iconpos="right">
<h3 class="collapsibleMainHeading">New {AppointmentTerm}</h3>
<p>
{AppointmentForm}
</p>
</div>
{MakeAppointment_stop}
[1] => MakeAppointment
[2] => MakeAppointment_stop
)
Index 0 is correct however 1 and 2 are not. 1 should have the register tags and content and 2 should not exist.
What am I doing wrong here?