this is the basic example, just adjust according to your needs
$var = '<B>username</B>:';
//username should be 1 or more characters
preg_replace('/<b>(.+)<\\/b>:/i','<b><a href="/$1">$1</a>',$var);
//sample when username should be 8 characters only
preg_replace('/<b>(.{8})<\\/b>:/i','<b><a href="/$1">$1</a></b>',$var);
//sample when username should be more than 7 characters
preg_replace('/<b>(.{8,})<\\/b>:/i','<b><a href="/$1">$1</a></b>',$var);
the (dot) there means it will match any single character except line break characters
the (i) delimiter there makes it case insensitive so for example it matches both B and b