I am trying to process something similar like shrotcode via preg_replace_callback function:
$new_content = preg_replace_callback("|\[BLOCK\s?(TYPE=[0-9a-z\/]+)?\s?(TEXT=[a-z]+)?\s?(LAST)?\s?\]((?:(?!BLOCK).)*)\[\/BLOCK\]|","block",$content);
The subject ($content) is for example this:
[BLOCK TYPE=1/2 TEXT=right LAST]
<ul><li>something</li>
</ul>
[/BLOCK]
[BLOCK TYPE=1/2 TEXT=right LAST][NEXTSHORTCODE=something][/BLOCK]
[BLOCK TYPE=1/2 TEXT=right LAST]123[/BLOCK]
I met a problem:
Function preg_replace_callback matches whole subject (from BLOCK to last /BLOCK) instead of first occurance of /BLOCK. I wanted to solve it excluding string BLOCK ((?:(?!BLOCK).)*) from inner content of a shortcode but it do not work with other characters like new line etc.
You can see my tries here: http://rubular.com/r/0AqadXVdON
Thank you for advise and sorry for bad english.