I am removing classes from a HTML element according to some conditions. This is my regex pattern:
elem.className = elem.className.replace(/shake|progress|done/g, '');
but this pattern has a problem that if somebody adds another class say shaker, that will also be removed. so I changed the pattern to:
elem.className = elem.className.replace(/(^|\s)shake(\s|$)|(^|\s)progress(\s|$)|(^|\s)done(\s|$)/g, '');
now it removes only if the whole word matches. but now it removes the spaces around the word. I am not sure how to fix this issue. please help me with this.
classListinstead./\b(?:shake|progress|done)\b/