Skip to content

Instantly share code, notes, and snippets.

@yitonghe00
Created September 12, 2021 00:21
Show Gist options
  • Save yitonghe00/d22d2345b700dfd2534f2ec4b700ee29 to your computer and use it in GitHub Desktop.
Save yitonghe00/d22d2345b700dfd2534f2ec4b700ee29 to your computer and use it in GitHub Desktop.
let text = "'I'm the cook,' he said, 'it's my job.'";
// Change this call.
console.log(text.replace(/(^|\W)'|'(\W|$)/g, '$1"$2'));
console.log(text.replace(/(^|\W)'/g, '$1"')); //Working as well due to the punctuation??
// → "I'm the cook," he said, "it's my job."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment