Created
May 4, 2015 00:54
-
-
Save JavaScript-Packer/7c03f918a01ac42f1554 to your computer and use it in GitHub Desktop.
Function to replace global using regex/regexp. Live demo on http://jsfiddle.net/v6f4nbhL/
This file contains hidden or 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
function replacer(W, H, A, K) { | |
K = W.replace(new RegExp(H, "g"), A); | |
return K; | |
} | |
var str = "WHom"; | |
var find = "Ho"; | |
var r3plac3 = "HAK\u002eco"; | |
alert(replacer(str, find, r3plac3)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment