My problem is i want to do something like this:
Javascript vaja => <b>Ja</b>vascript va<b>ja</b>
i.e i have a query string(ja) and i want to replace all the occurances(case insensitive) of that query string in a bigger string (Javascript vaja).
The closest solution i have right now is:
"Javascript vaja".replace(/ja/gi, '<b>ja</b>');
which gives me:
"<b>ja</b>vascript va<b>ja</b>"
but what i need is:
Javascript vaja => <b>Ja</b>vascript va<b>ja</b>
one solution that i have in mind is to keep the indexes of upcase letters before replacement and then re replace them. But that is way too hacky. I am pretty sure i am not the first one trying this and pretty sure there is some elegant and simpler solution hidden somewhere.