I have this Regexp:
/\{%\s([^else|endloop|endif][a-z0-9\.\|_]+)\s%\}/si
I use this regexp in preg_replace.
And this markup:
{# comment %}
{# comment number 2$% %}
{% variable %}
{% array.key1.key2 %}
{% array.key1.key2|escape|bold %}
{% variable|escape %}
{% loop array as item %}
My item is {% item.text %}
{% endloop %}
{% if (something): %}
do something truly
{% else: %}
nothing to do
{% endif; %}
Why this regexp is not working for {% item.text %} but works with other?
I think that I made some mistake here [^else|endloop|endif]
What I’m doing wrong?
I think you may intend:
The square brackets previously containing the
else,endloopandendifkeywords treats each individual character as an exception. Here they are treated as whole strings.