I'm trying to remove the fullstops, commas and spaces from a string. I'm pretty sure I have to do this using this: str.replace(<some Regex here>, "");
I'm just not very familiar with Regex, how can I accomplish this?
Use this regex /[.,\s]/g
var str = 'abc abc a, .aa ';
var regex = /[.,\s]/g;
var result = str.replace(regex, '');
console.log(result);
You don't need to escape character except ^-]\ in character class []
Any character except ^-]\ add that character to the possible matches for the character class.
. in the brackets unless you're escaping the ] since the matches are literal.] and ^ within regex square brackets if trying to literally match those characters. Maybe a few others I missed. Not relevant to the question or answer; just correcting my above comment.