Reputation: 5308
Please look this JsFiddle.
var target = "Thanks For Looking This Problem";
var phrase = ["anks", "for", "king T"];
for(var indx = 0; indx < phrase.length; indx ++)
{
target = target.replace(new RegExp(phrase[indx], "gi"), "~~~" + phrase[indx]+ "```");
}
I get this output: Th~~~anks``` ~~~for``` Loo~~~king T```his Problem
But I need this output: Th~~~anks``` ~~~For``` Loo~~~king T```his Problem
'For' instead of 'for'
Upvotes: 0
Views: 84