Forum Moderators: coopster
$string = '<!-- START comment --> random text... <!-- END comment -->';
$cb = preg_quote('<!--'); // comment begin
$ce = preg_quote('-->'); // comment end
print preg_replace("/($cb.*$ce).*($cb.*$ce)/Us", "$1My replacement text$2", $string);