Skip to content

Instantly share code, notes, and snippets.

@dustinpoissant
Created November 11, 2016 15:36
Show Gist options
  • Save dustinpoissant/487ea9bd9703f52b5e5c7fcdc91aec71 to your computer and use it in GitHub Desktop.
Save dustinpoissant/487ea9bd9703f52b5e5c7fcdc91aec71 to your computer and use it in GitHub Desktop.
Replace all occurrences in a string
String.prototype.replaceAll = function(search, replacement) {
var target = this;
return target.replace(new RegExp(search, 'g'), replacement);
};
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