I want to use this function but preserving the uppercase or lowercase so for example having something like
var value = 'Replace a string';
var search = 'replace';
value.replace(search, "<span style='font-weight: bold'>"+search+'<span>');
And the output of value be:
Replace a string
Since you’re leaving the word itself as-is, you can use a simple regex:
The
$&indicates the matched pattern.