I use RegExp and \"string\".match very rarely so I\'m not so sure how to use them for some little bit complex things.Here\'s what I would like to do and don\'t know how to d
var str = " I would like to know how to use RegExp , string.match and string.replace";
console.log(
str
);
console.log(
str
//Replace double space with single
.replace(/ +/ig, ' ')
);
console.log(
str
//Replace double space with single
.replace(/ +/ig, ' ')
//Replace any amount of whitespace before or after a `,` to nothing
.replace(/\s*,\s*/ig, ',')
);