Created
October 30, 2020 10:28
-
-
Save karimkod/4c68c4a3a9f013dba02bf3e15028ae5f to your computer and use it in GitHub Desktop.
RegEx used with String.protoype.replace to replace all single quotes with double quotes in the text and ignoring single quotes used for contractions.
This file contains hidden or 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
//Replace Single quote with double quote in a text regularExpression. | |
let reg = /([^\w])'(.+)'([^\w])/ig; | |
let text = "and then he said : 'Oh no rick, don't kill me please'. And rick replied : 'frick off kid' knowing he won't."; | |
let replaced = text.replace(reg, '$1"$2"$3'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment