- preg_replace_callback: documentation ( source)
- preg_replace: documentation ( source)
<?php
$str = <<<STR
...
rule
one, two, three,
/* comment1
comment1.1 */
four, five,
/*comment2*/
six
end
STR;
echo preg_replace_callback(
'~rule(.*?)end~s',
function ($match) {
return preg_replace('~/\*.*?\*/~s', '', $match[1]);
},
$str
);