savetheorcas
asked on
Help w/RegEx Needed
I need a RegEx pattern which tells me if the first character in a string is a 1 or not. This is going to be used on a telephone number like 15551234567. What I need to do is write a javascript function using RegEx to determine if the first character in the strong (telephone number) is a 1.
Tried all sorts of different snippets from the web, but nothing seems to be working and I am very new at this RegEx things.
Thanks
Tried all sorts of different snippets from the web, but nothing seems to be working and I am very new at this RegEx things.
Thanks
'^1\d{10}'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
actually for a US phone number the regex should be (without dashes)
^1[2-9]\d{9}
with dashes
^1[2-9]\d{2}-\d{3}-\d{4}$
^1[2-9]\d{9}
with dashes
^1[2-9]\d{2}-\d{3}-\d{4}$
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window