I have a PHP page that is reading text stored in a MYSQL database table.
The text might look something like this
Bob: Hi blah blah
(Bob walking around)
Fred Johnson: blah blah blah
Bob: Something something: something
I want to do a preg_replace to bold everything that comes before the first colon in each line.
So in this situation only the names would be bold and on that last line “Something something” would not be bold
What I have now bolds everything on each line that comes before any colon
$reg='(.*\w:)';
$text = preg_replace("/".$reg."/", "<b>\${1}</b>", $text);
You can use:
See it