Skip to content

Instantly share code, notes, and snippets.

@chris-sev
Created December 1, 2018 18:54
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 chris-sev/fcd4396ee879d3ccc306512a59e2608a to your computer and use it in GitHub Desktop.
Save chris-sev/fcd4396ee879d3ccc306512a59e2608a to your computer and use it in GitHub Desktop.
Replace All with RegExp()
const myMessage = 'this is the sentence to end all sentences';
const newMessage = myMessage.replace(new RegExp('sentence', 'g'), 'message');
console.log(newMessage); // this is the message to end all messages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment