Hmm, there is one more possible situation which could happen: two snippet calls on the same line. For example:
[!Snippet1? ¶m1=`xx` &id=`` ¶m2=`zz`!] hello [!Snippet!]
Your current regexp ’eats’ hello as well but it shouldn’t. For this particular case is my regexp ’~\[\!.+\!\]~Us’ better but my regexp on the other hand fails with imbricated calls (as you mentioned). Well, it is definitely not going to be easy to fix, good luck with that
You’re right, Sunday afternoon isn’t a good time, especially when I am supposed to learn for school
http://tobik.pastebin.com/GJkMinz9
This is the document which triggered all this. There’s nothing special about it, I just put each argument on a single line to make it better readable. And that was the problem.
Btw. Ditto has the similar feature which excludes given snippets from the output code. It might help you with finding the best solution.