Remove () and - and white spaces from phone number in Javascript
You can use String.replace() to do this. Pass it a RegExp that matches everything but digits and replace them with ''
.
var number = '(123) 456-7891';
number = number.replace(/[^\d]/g, '');
To be on the safe side, I would recommend removing everything except +
(for country codes) and digits:
result = subject.replace(/[^+\d]+/g, "");