Я знаю, что это старый, но я не видел никого, кто бы упоминал расширение строки prototype
.
String.prototype.replaceAll = function(search, replace){
if(!search || !replace){return this;} //if search entry or replace entry empty return the string
return this.replace(new RegExp('[' + search + ']', 'g'), replace); //global RegEx search for all instances ("g") of your search entry and replace them all.
};