- preg_split: documentation ( source)
<?php
$value_pattern = "\"(?:[^\"]|\")*\"";
$variable_pattern = '\w+ *\= *' . $value_pattern;
$block_pattern = "\[(?:[/]|\w)+(?: +' . $variable_pattern . ')*\]";
$input = 'Some text broken by an [img src="resx/img.jpg" alt="" full] and more text below.';
echo $block_pattern;
$tokens = preg_split('/'.$block_pattern.'/', $input, -1, PREG_SPLIT_DELIM_CAPTURE);