I give up! I need a Regex to get just the area code and phone number but not the country code.
My data looks like this:
7781234567
But it can also look like this:
17781234567
I want to capture 7781234567
The first example is not a problem but the second example I just want to capture the rest of the phone number but not the “1”. And it is just “1” I want to get rid of. There are no other numbers in my data set that I want to remove from the front. And of course I want “1” if it is part of the phone number but not the country code. Plus there are no “-“ or spaces. My data looks exactly like I have it here. I promised I tried looking it up on the Internets but just could not find the right solution.
The only thing I can think of is trying to compare the beginnings of the phone numbers with a list like this one on wikipedia (maybe pared down specifically for your data set). But that can’t be done with a regex and without leading zeros it still might be impossible. Of course I don’t know the specifics of your country’s phone number system.
Sorry. Not making myself clear. The only number ahead of phone numbers I have are “1”. Most of the phone numbers don’t have a leading “1” but when my JavaScript comes across the phone numbers that do have a leading “1” I want to get rid of the “1” and keep the rest of the phone number. I could just split the numbers and have an if statement that says if the the first number begins with a one then just get the rest of the split numbers and combine them again. But I would prefer Regex solution. I should also add none of the phone numbers begin with a “1” except those that include the country code. So a Regex that gets rid of all leading “1”s would do the trick.