Genesys Cloud - Main

 View Only

Sign Up

  Thread closed by the administrator, not accepting new replies.
  • 1.  Regex ^8[0-9]{7}[a-zA-Z]

    Posted 12-21-2022 11:31
    No replies, thread closed.
    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
    ------------------------------


  • 2.  RE: Regex ^8[0-9]{7}[a-zA-Z]

    Posted 12-21-2022 11:50
    No replies, thread closed.
    Hi Thomas,

    Are you using a regex testing tool like https://regexr.com/ ? This is very helpful in ensuring you have an accurate regular expression that matches all of the test cases you need to concern yourself with.

    It appears that your regex
    ^8[0-9]{7}[a-zA-Z]​

    will work against values like:

    83443434A
    82902392q

    but not:

    93233223B
    23083408a
    8ss8sd8dA
    834734978340
    37443097438889A

    Hope this is helpful info and will help you resolve your issue!

    Brian



    ------------------------------
    Brian Goad
    Genesys - Employees
    ------------------------------



  • 3.  RE: Regex ^8[0-9]{7}[a-zA-Z]

    Posted 12-21-2022 14:02
    No replies, thread closed.
    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
    ------------------------------



  • 4.  RE: Regex ^8[0-9]{7}[a-zA-Z]

    Posted 12-22-2022 03:29
    No replies, thread closed.
    Thank you Paul and Brian, really helped me. The Regex for my use case in fact is ^8[0-9]{6}[a-zA-Z]

    ------------------------------
    Thomas Repking
    Canada Life Group Services Limited
    ------------------------------



  • 5.  RE: Regex ^8[0-9]{7}[a-zA-Z]

    Posted 02-20-2023 13:24
    No replies, thread closed.

    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.
    ------------------------------



  • 6.  RE: Regex ^8[0-9]{7}[a-zA-Z]

    Posted 02-20-2023 13:49
    Edited by Paul Simpson 02-20-2023 14:40
    No replies, thread closed.

    ^(\+?1)?8[0-9]{9} 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
    ------------------------------



  • 7.  RE: Regex ^8[0-9]{7}[a-zA-Z]

    Posted 02-20-2023 14:23
    No replies, thread closed.

    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.
    ------------------------------



  • 8.  RE: Regex ^8[0-9]{7}[a-zA-Z]

    Posted 02-20-2023 14:40
    No replies, thread closed.

    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
    ------------------------------