I would like the search a string without case sensitive however change the sub string with original string's case letters.
var mystring = "FiRst Last";
var term = "first"; // it could be "FIRST" or fIRST
var re = new RegExp("^" + term, "i") ;
//option 1
//var t = mystring.replace(re,"<span style='font-weight:bold; color:Blue;'>" + term + "</span>");
//option 2
var t = mystring.replace(re,term.bold().fontcolor("Blue"));
The above code gives first LAST in blue color, however i want it to be FiRst LAST as mystring's case order
maybe indexof() method can be used however there might be an easy efficient way.