preg_replace_callback(
'/\b(these|are|bad|words|like|ass)\b/',
function (array $match) { return str_repeat('*', strlen($match[1])); },
$comment
)
\b
is a word boundary and will probably suffice for most cases; though it probably won't be perfect for all cases.