Skip to content

Instantly share code, notes, and snippets.

@ryasmi
Last active December 16, 2015 11:09
Show Gist options
  • Save ryasmi/5425638 to your computer and use it in GitHub Desktop.
Save ryasmi/5425638 to your computer and use it in GitHub Desktop.
Replaces all occurrences of a string (x) within a string (this) with another string (y).
// Using func. https://gist.github.com/ryansmith94/5564105
func("replaceAll", function (x, y) {
var self = this;
while (self.indexOf(x) !== -1) {
self = self.replace(x, y);
}
return self;
}, String.prototype);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment