Skip to content

Instantly share code, notes, and snippets.

@marcbacon
Created January 20, 2016 23:20
Show Gist options
  • Save marcbacon/7ce9c091baa426494de0 to your computer and use it in GitHub Desktop.
Save marcbacon/7ce9c091baa426494de0 to your computer and use it in GitHub Desktop.
Replace all iterations of a string (within a string) with other content.
/*
* Function to replace all iterations of one string with another
*/
function replaceAll(str, find, replace) {
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