I'm looking to parse some formatting out of a field using javascript. My rule is catching some extra things which I need to fix. The regex is:
/[\((\)\s)-]/g
This regex is properly cleaning up: (123) 456-7890 the problem I'm having is that it is also removing all spaces rather than just spaces following a closing parentheses. I'm no expert in regex but it was my understanding that (\)\s) would only remove the closing parentheses and space combo. What would the correct regex look like? It needs to remove all parentheses and dashes. Also, only remove spaces immediately following a closing parentheses.
The outcomes I would like are such.
The replace method i am using should work as such
var str = mystring.replace(/[\((\)\s)-]/g, '');
(123) 456-7890 should become 1234567890 which is working.
leave me alone should stay leave me alone the issue is that it is becoming leavemealone