Skip to content

Instantly share code, notes, and snippets.

@guaiamum
Created December 5, 2017 17:33
Show Gist options
  • Save guaiamum/95ae79dfb130ada21557a3516e198b0d to your computer and use it in GitHub Desktop.
Save guaiamum/95ae79dfb130ada21557a3516e198b0d to your computer and use it in GitHub Desktop.
Replace all occurrences on string, using regular expression
String.prototype.replaceAll = function(search, replacement) {
var target = this;
return target.replace(new RegExp(search, 'g'), replacement);
};
var str = "oi, tchau, adios, bye, etc";
str.toString().replaceAll(',','\n');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment