note
sutch
This:<br>
<code>(.*?)\s*(.*?)\s*</code><br>
can be problematic. Since LABEL and PARAMETER must not contain spaces, try replacing that portion with something like:<br>
<code>([^\s]+)\s+([^\s]+)?</code><p>
I'd also suggest that you change *? to simply *, since * denotes 0 or more occurances.<p>
Probably the biggest problem is the:<br>
<code>(.+?)</code><br>
which occurs just before:<br>
<code><%end_\1%></code><br>
and matches to the end of the string, which then causes the regex engine to backtrack each time it cannot find each "end" tag.<p>
You may also want to take a look at the book "Mastering Regular Expressions" by Jeffrey E. Friedl. See [id://21667|Mastering Regular Expressions] for a review.
240648
240648