I am using jQuery to find text in an html and highlight all occurrences of a text, replacing them for a span tag.
<div>This a sample paragraph. Sample is it?</div>
I am using the following piece of code to replace all occurrence of a word
var $test = $('div').html();
$test = $test.replace( new RegExp('sample',"g"), '<span class="hilite">sample</span>'
I would like to change all occurences of sample
doesn't matter how it is written [Sample, SAMPLE, samplE]
I would like to highlight the intended word, how could I do it?