/ Published in: JavaScript
This snippet adds a replaceAll method to the String prototype, so that you can call it later like this: "test string".replaceAll("s", "-"); // returns "te-t -tring"
Expand |
Embed | Plain Text
String.prototype.replaceAll = function(pcFrom, pcTo){ var i = this.indexOf(pcFrom); var c = this; while (i > -1){ c = c.replace(pcFrom, pcTo); i = c.indexOf(pcFrom); } return c; }
You need to login to post a comment.
