Skip to content

Instantly share code, notes, and snippets.

@CharlesAMoss
Created September 27, 2015 04:19
Show Gist options
  • Save CharlesAMoss/090f5cdb53e5a37cb121 to your computer and use it in GitHub Desktop.
Save CharlesAMoss/090f5cdb53e5a37cb121 to your computer and use it in GitHub Desktop.
these are the jokes
var x = "great sadness";
var great_magic = function ( str ) {
var result = str.replace(new RegExp(("\\b" + "sadness" + "\\b"), 'g'), "happiness");
return result;
};
console.log(great_magic(x)); // logs "great happiness"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment