1var str = "Please locate where 'locate' occurs!";
2
3str.replace("locate", "W3Schools"); //replace only replace first match from string
4str.replace(/LOCATE/i, "W3Schools"); // i makes it case insensitive
5str.replace(/LOCATE/g, "W3Schools"); // g replace all matches from string rather than replacing only first
6
7document.write("<br>" + "replace:", res7);
8document.write("<br>" + "replace with case insensitive:", res8);
9document.write("<br>" + "replace all:", res9);