Javascript, untested fixed:
yourstring.replace(/([kK])/g, "<span class='styled'>$1</span>");
Working example:
<html><head></head><body> <div id='target'> some text with little ks and big Ks and a few more for good measure kK7k9Kii </div> </body></html> <script type='text/javascript'> target = document.getElementById('target'); target.innerHTML = target.innerHTML.replace(/([kK])/g, "<span style='color:red'>$1</span>"); </script>
MDN .replace() documentation here .
source share