Created
August 30, 2012 01:52
-
-
Save james2doyle/3521579 to your computer and use it in GitHub Desktop.
replaceAll
This file contains 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(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