- preg_replace: documentation ( source)
<?php
$input = [
'<p>test:</p>',
'<p>test: foo</p>',
'<p>foo:</p>',
'<p>: foo</p>',
'<p>test </p><p>:</p>',
];
foreach ($input as $val) {
echo(preg_replace('/(<p>)([^<]+?:)(.*)/', '$1<strong>$2</strong>$3', $val));
echo("\n");
}