Hmm, after testing the new pattern out (thanks d11wtq!), I find them too slow. I came up with a new idea of enabling nested matches; Let the beginning and ending tags contain an optional key. If the key is included in the open tag, the ending tag must also contain it. I edited my old pattern too make it work like this:
Code: Select all
#<\{if\((.*?)\)(\:їa-z0-9_]*)?\}>(.*?)<\{endif(\:\\2)?\}>#s
However, thid does not work at all, but I think you'll get the idea of what I'm trying to accomplish.
This one does however work pretty good, but it requires the key:
Code: Select all
#<\{if\((.*?)\):(їa-z0-9_]*)\}>(.*?)<\{endif:\\2\}>#s
The biggest problem is still that if the match contains a match, the match inside won't be matched.
Is there any way to make the preg_ functions start from the bottom? This would solve all the problems, neither keys or looking for nested matches would be needed since the first match would always be correct.
Thanks for all the replies btw
