My problem is, that this:
preg_replace(\'/(?<=\\>)\\b\\w*\\b|^\\w*\\b/\', \'$&\', $string);
Does not work and
Try with this instead
preg_replace('/(?<=\>)\b\w*\b|^\w*\b/', '<b>$0</b>', $string);
$0 means it will become the first thing matched in your regex, $1 will become the second etc.
You could also use back-references; \0 gets the first thing matched back from where you are, \1 gets the second thing matched back etc. More Info
You need to put a number after $
to refer to grouped part of the regex.Here it would be first group , hence 0. Working example here : http://codepad.org/4V7GWdja
<?php
$string = "an example";
$string = preg_replace('/(?<=\>)\b(\w*)\b|^\w*\b/', '<b>$0</b>', $string);
var_dump($string);
?>
$string = 'an example';
echo preg_replace('/^\b(.+?)\b/i', '<b>$1</b>', $string);
// <b>an</b> example