Last active
December 16, 2015 11:09
-
-
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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