Kitefr, (this isn’t really a WordPress question, but a php one) but you could usepreg_replace_callback
, in which you define your own function to handle the the replacement.
For instance,
$text = "The quick brown fox jumped over the Quick dog.";
$text = preg_replace_callback( "/quick/si", 'my_replace' , $text );
function my_replace($matches){
return '<strong>'.$matches[0].'</strong>';
}
This replaces all instances of ‘quick’ (in any case) and wraps them with strong tags, leaving the case of the letters unchanged. You could do something similar with link tags