For the moment, I get the better results with : ’~\[!(.*?)!\]~is’
<?php
$text1= '[!snippet? ¶m=`Hello world!`!]';
$text1 = preg_replace('~\[!([^!]*)!\]~is', '', $text1);
echo "text1=".$text1;
echo "<br />";
$text2= '[!snippet? ¶m=`Hello world!`!]';
$text2 = preg_replace('~\[!(.*?)!\]~is', '', $text2);
echo "text2=".$text2;
echo "<br />";
$text3= '[!snippet?
¶m=`Hello world!`
!]
';
$text3 = preg_replace('~\[!(.*?)!\]~is', '', $text3);
echo "text3=".$text3;
echo "<br />";
$text4= '[!Snippet1? ¶m1=`xx` &id=`[!Snippet2!]` ¶m2=`zz`!]';
$text4 = preg_replace('~\[!(.*?)!\]~is', '', $text4);
echo "text4=".$text4;
echo "<br />";
?>
But it doesn’t work If I have an imbricated call like: [!Snippet1? ¶m1=`xx` &id=`[!Snippet2!]` ¶m2=`zz`!]
I think I need to use assertions (lookahead) to detect if the next !] belongs or not to the same snippet call. Not easy for a sunday
Could you post your first snippet call which oblige you to improve the stripOutput. Thanks.
EDIT: I didn’t read carefully your post If I use ’~\[!(.*?)!\]~Us’, I remove all the snippets calls
<?php
$text4= '[!Snippet1? ¶m1=`xx` &id=`[!Snippet2!]` ¶m2=`zz`!]';
$text4 = preg_replace('~\[!(.*?)!\]~Us', '', $text4);
echo "text4=".$text4;
echo "<br />";
$text5= '[!Snippet1? ¶m1=`xx`
&id=`[!Snippet2!]` ¶m2=`zz`!]
xxxxxxxxxxxxxxx
[!snippet3!]
';
$text5 = preg_replace('~\[!(.*?)!\]~Us', '', $text5);
echo "text5=".$text5;
echo "<br />";
?>