var re = /apples/gi;
var str = "Apples are round, and apples are juicy.";
var newstr = str.replace("apples", "oranges","gi");
document.write(newstr);
It should output oranges are round, and oranges are juicy. , because of the case insensitivity, but instead it outputs Apples are round, and oranges are juicy.
Why??