No, you should use {9} (my mistake - I have corrected).
Numbers in braces means "repeat what came immediately before", so [0-9]{9} means 9 digits, so with the 8, that makes 10.
The \ means the next character is literal, so \+ matches the +
The ? means what is before is optional, so \+? means an optional +
We than have (\+?1)? means optionally a 1 which is preceded, optionally, by a +.
So, put it all together and you have an optional 1 or +1, followed by an 8, followed by 9 more digits.
If you wanted to guarantee it was a valid NANP, (Exchange cannot begin with a zero or a 1) you would need ^(\+?1)?8[0-9]{2}[2-9][0-9]{6}
To further validate, not all area codes starting 8 are Toll Free, so you would need to look at the next two digits and ensure they come from a list of valid options....
------------------------------
Paul Simpson
Eventus Solutions Group
------------------------------
Original Message:
Sent: 02-20-2023 14:23
From: Bassel Nafaa
Subject: Regex ^8[0-9]{7}[a-zA-Z]
Thank you Paul for your quick response.
Just to be sure because this is a Toll Free 10 digit number . should we use {8} instead of {7} ?
Best
BN
------------------------------
Bassel Nafaa
Prospero Management Services, LLC.
Original Message:
Sent: 02-20-2023 13:49
From: Paul Simpson
Subject: Regex ^8[0-9]{7}[a-zA-Z]
^(\+?1)?8[0-9]{7} should get you most of the way there (1 is optional, + is optional, but if present, must be followed by a 1)
You need to get creative if you also want to verify a valid NANP number (Area Code and Exchange cannot be 0 or 1) and if you require it to allow formatting characters (like parentheses, spaces and hyphens.)
Let us know if you need that as well!
------------------------------
Paul Simpson
Eventus Solutions Group
Original Message:
Sent: 02-20-2023 13:24
From: Bassel Nafaa
Subject: Regex ^8[0-9]{7}[a-zA-Z]
HI Guys,
Do you know if there is a standard formula that can match any Toll-free number in general? ex. 1 8xx-xxx-xxxx or +1 8xx-xxx-xxxx
Thanks
------------------------------
Bassel Nafaa
Prospero Management Services, LLC.
Original Message:
Sent: 12-21-2022 14:01
From: Paul Simpson
Subject: Regex ^8[0-9]{7}[a-zA-Z]
Thomas,
Your Regex is looking for an 8-digit number with the first digit being an 8. (8 followed by 7 more digits 0-9.)
In your requirement, you state that you need 7 digits followed by a letter, so you will need {6} not {7}.
Also, what do you mean by "alphanumeric 7-digit number". Do you mean you need 8 characters, where the first is an 8 and the last is a letter, but the middle 6 can be alphanumeric?
HTH
------------------------------
Paul Simpson
Eventus Solutions Group
Original Message:
Sent: 12-21-2022 11:31
From: Thomas Repking
Subject: Regex ^8[0-9]{7}[a-zA-Z]
Hi, I want a speech bot to recognize an alphanumeric 7 digit number followed by a letter and starting with an 8. The Regex I thought should work is ^8[0-9]{7}[a-zA-Z] but this is not the case. Any idea as to what it has to look like?
#ConversationalAI(Bots,AgentAssist,etc.)
------------------------------
Thomas Repking
Canada Life Group Services Limited
------------------------------