I need a help with this regexp..
using
/\{block:(Posts|Photos|Videos)(\s\[.*?\])?\}(\s?[^\"]+\s?)\{\/block\}/U
i get {block:Posts}abcdef{/block}
from this:
<div>
{block:Posts [a=1, b=2]}
abcdef
{/block}
</div>
But if my text is like this:
<div>
{block:Posts [a=1, b=2]}
{block:Text}
abcdef
{/block}
{/block}
</div>
i get {block:Posts}{block:Text}abcdef{/block}
because it's based on the first {/block}
found in text.
A simple way to avoid this is using {/block:Posts}
to close the block, but how can I do that since the opening block tag is optional (Posts|Photos|Videos)? If I open the block with Photos I must be sure it has to be closed with {/block:Photos}
.
Using /\{block:(Posts|Photos|Videos)(\s\[.*?\])?\}(\s?[^\"]+\s?)\{\/block\:(Posts|Photos|Videos)\}/U
of course doesn't help...
Can anyone please help me?
Thanks!!
PS
Is it possible, modifying the regex above, to get the optional parameters a
and b
as an array?