Hi again,
Although I haven't got an actual use for this yet I've been thinking. From the code that was helpfully provided, you can't put variables into the function, i.e., gallery($username). Is there a solution to this or should it actually work and I'm just being a spanner
<?php
$s='text, e.g. [!gallery!], that is contained in blog post';
$p=',\[!([^!]+)!\],';
$s=preg_replace_callback($p,
function ($match) {return $match[1]();}, // calls gallery()
$s);
function gallery() {return '//function GALLERY was here//';}
echo $s;
?>