Following this question How can I strip all punctuation from a string in JavaScript using regex? I'm trying to remove all punctuation from a string besides the '
character to avoid messing with words such as:
- wouldn't
- don't
- won't
So far I have tried the following:
return word.replace(/[^\w\s]|_\'/g, "")
.replace(/\s+/g, " ");;
But it is still removing the '
character. Any idea how I can achieve such a result?