GotoIf Double Pattern Match [SEC=UNCLASSIFIED]

Home » Asterisk Users » GotoIf Double Pattern Match [SEC=UNCLASSIFIED]
Asterisk Users 1 Comment

Hi guys,

Sorry if this is a really basic question, but I’m fairly new to Asterisk and am self-teaching so please go easy on me 🙂

Basically what I am trying to do is match 2 patterns in a conditional GotoIf. The first condition is that the callerid(num) must end in ’13’
The second condition is that the first two digits of callerid(num) must be one of 66,77,88 or 99
eg. 9913 would match, but 9013 would not. 6613 would match, but 6612 would not.

What I have written come up with is below, but I just wanted to see if I was going about this the right way, and that this expression would actually work…

exten => B,n,GotoIf($[“${CALLERID(num):-2}” = “13”] & $[“${CALLERID(num):0:2}” = [5-9][5-9])?change_context)

Any advice/suggestions/flames welcome 🙂

Cheers Calum

One thought on - GotoIf Double Pattern Match [SEC=UNCLASSIFIED]

  • –Apple-Mail=_0B1252DB-01F1-4EBB-9568-514789A88B0E
    Content-Transfer-Encoding: quoted-printable Content-Type: text/plain;
    charset=us-ascii

    Hi Calum

    I think you’ll need another closing square-bracket at the end of the second conditional test in your example, ie: 5-9]])?cha

    I also think you may need to wrap that second conditional up in the REGEX function, although there are much smarter people on-list who will likely come back with a better suggestion!

    Also, checking the second character of CID is the same as the first character (otherwise you’d match 56, 69, 97 etc).

    I’m thinking something like:

    $[${REGEX(“[5-9]” ${CALLERID(num):0:1})}] & $[${CALLERID(num):0:1} = ${CALLERID(num):1:1}]

    Hope this helps anyway 🙂

    Pete

    –Apple-Mail=_0B1252DB-01F1-4EBB-9568-514789A88B0E
    Content-Transfer-Encoding: quoted-printable Content-Type: text/html;
    charset=us-ascii

    On 28/11/2016, at 12:29 pm, Calum Power <Calum.Power@aad.gov.au> wrote:


    <snip>


    What I have written come up with is below, but I just wanted to see if I was going about this the right way, and that this expression would actually work…
     
    exten => B,n,GotoIf($[“${CALLERID(num):-2}” = “13”] & $[“${CALLERID(num):0:2}” = [5-9][5-9])?change_context)
     
    Any advice/suggestions/flames welcome J

    Hi Calum


    I think you’ll need another closing square-bracket at the end of the second conditional test in your example, ie:  5-9]])?cha

    I also think you may need to wrap that second conditional up in the REGEX function, although there are much smarter people on-list who will likely come back with a better suggestion!

    Also, checking the second character of CID is the same as the first character (otherwise you’d match 56, 69, 97 etc).

    I’m thinking something like:

    $[${REGEX(“[5-9]” ${CALLERID(num):0:1})}] & $[${CALLERID(num):0:1} = ${CALLERID(num):1:1}]

    Hope this helps anyway 🙂

    Pete






    –Apple-Mail=_0B1252DB-01F1-4EBB-9568-514789A88B0E

LEAVE A COMMENT