Skip to content

Instantly share code, notes, and snippets.

@rafaelmaeuer
Created October 9, 2017 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelmaeuer/4cb0279fa18bf4401ca9c73b9fa6e483 to your computer and use it in GitHub Desktop.
Save rafaelmaeuer/4cb0279fa18bf4401ca9c73b9fa6e483 to your computer and use it in GitHub Desktop.
How to replace all occurrences of a string in JavaScript? - From https://stackoverflow.com/questions/1144783/how-to-replace-all-occurrences-of-a-string-in-javascript
String.prototype.replaceAll = function(search, replacement) {
var target = this;
return target.split(search).join(replacement);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment