Created
November 11, 2016 15:36
-
-
Save dustinpoissant/487ea9bd9703f52b5e5c7fcdc91aec71 to your computer and use it in GitHub Desktop.
Replace all occurrences in a string
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
String.prototype.replaceAll = function(search, replacement) { | |
var target = this; | |
return target.replace(new RegExp(search, 'g'), replacement); | |
}; |
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
String.prototype.replaceAll=function(a,b){var c=this;return c.replace(new RegExp(a,"g"),b)}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment