i have template engine. when matching {if}...{/if} block, content splitting by {else|elif} condition.
But when content have nested {if}...{/if} block, {else|elif} condition algorithm matching wrong else or elif tags.
maybe i have a content like this;
black line should selectable but red line unselectable.
this is my old matching pattern but it's not working properly
/{(else|elif)[\s]*(.*?)[\s]*}/
preg_match_all("/\{\/if}(.*?)\{if \$test3 \}/ms", $input_lines, $output_array);
Echo $output_array[1];
See it in action http://www.phpliveregex.com/p/fhf
(You need to push the preg_match_all-button for it to work)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.