I am learning regex and I want to do regex matching. However, I can't escape single quote properly using code the below. So, I am getting " [ 'Hell\'o', 'World' ] ". Probably I can use /[^\s]+/g for the quick answer " [ 'Hell'o', 'World' ] " other than the code below. However, it's hard for me to understand how regex system works if I use it. Is it possible to use other regex matching tokens for escape single quote when it outputs?
function printWords(str) {
var count = 0;
var arr = str.match(/[\w’]+/g);
console.log(arr);
}
printWords("Hell'o World ")
--