Skip to content

Instantly share code, notes, and snippets.

@JavaScript-Packer
Created April 29, 2015 02:29
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 JavaScript-Packer/175019a2007ad57beb47 to your computer and use it in GitHub Desktop.
Save JavaScript-Packer/175019a2007ad57beb47 to your computer and use it in GitHub Desktop.
A JavaScript function that multi replaces many things to one same thing, use any regexp for split
function replacer(s, f, r) {
//s=string
//f=find
//r=replace
return s.split(RegExp(eval(f))).join(r);
}
alert(replacer("480Vi76s76i5t7 7w5876w87w58.5W76H2A56K.2134c54o67m0", "/[0-9]/g", ""));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment