Skip to content

Instantly share code, notes, and snippets.

@jswhisperer
Created November 20, 2013 17:37
Show Gist options
  • Select an option

  • Save jswhisperer/7567519 to your computer and use it in GitHub Desktop.

Select an option

Save jswhisperer/7567519 to your computer and use it in GitHub Desktop.
// Mistake
var str = "David is an Arsenal fan, which means David is great";
str.replace("David", "Darren"); // "Darren is an Arsenal fan, which means David is great"
// Desired
str.replace(/David/g, "Darren"); // "Darren is an Arsenal fan, which means Darren is great"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment