hankknight
asked on
Strong from to : only if there is a :
The only problem with this is that it makes text bold even if there is no :
Test it and you will see the problem.
Test it and you will see the problem.
<?php
$str = '
This should be bold: this should not be bold
<p>Intro text: this is a test.</p>
<p>Hello world: How are you?</p>
<p>This text should not be bold because there is no colon. Test 123.</p>
<p>Foobar: Zooph.</p>';
$str = preg_replace('/(^|<p>)([^:]+):/ims', '\1<strong>\2:</strong>', $str);
echo $str;
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.