Skip to content

Instantly share code, notes, and snippets.

@johsh
Created March 14, 2014 14:11
Show Gist options
  • Select an option

  • Save johsh/9548416 to your computer and use it in GitHub Desktop.

Select an option

Save johsh/9548416 to your computer and use it in GitHub Desktop.
js, replaceAll instead of replace (first)
//find = this has to be replaced...
//replace = with that str
//str = in this str, please
function replaceAll(find, replace, str) {
return str.replace(new RegExp(find, 'g'), replace);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment