Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Created August 30, 2012 01:52
Show Gist options
  • Save james2doyle/3521579 to your computer and use it in GitHub Desktop.
Save james2doyle/3521579 to your computer and use it in GitHub Desktop.
replaceAll
String.prototype.replaceAll = function(str1, str2, ignore) {
return this.replace(new RegExp(str1.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g, "\\$&"), (ignore ? "gi" : "g")), (typeof(str2) == "string") ? str2.replace(/\$/g, "$$$$") : str2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment