Created
September 12, 2021 00:21
-
-
Save yitonghe00/d22d2345b700dfd2534f2ec4b700ee29 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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