How can I remove all non 10 digit numbers from a string, and add a +1 to the front of it if it doesn't exist yet?
Here's the regex code I have:
phoneNumber.replace(/[^0-9.\,]/g, '');
phoneNumber = '+1' + phoneNumber;
but this won't work if phoneNumber
already has +1
. How can I make it that the regex first removes all non numerical, and adds a prefix of +1?