Here's another implementation of String.replaceAll()
method
String.prototype.replaceAll = function(search, replace) {
if (replace === undefined) {
return this.toString();
}
return this.split(search).join(replace);
}
The difference between this one and solution posted here is that this implementation handles correctly regexp special characters in strings as well as allows for word matching