Problems With REGEXP – Anchor String To Beginning

Home » Asterisk Users » Problems With REGEXP – Anchor String To Beginning
Asterisk Users No Comments

This is a multipart message in MIME format.

——=_NextPart_000_001D_01D22B16.681DE430
Content-Type: text/plain;
charset=”us-ascii”
Content-Transfer-Encoding: 7bit

In extensions, I have this.

The variable “oex” contains the original extension called, and is used to route outgoing calls internal or external depending on several factors.

But now, im implementing a system that should require a passcode upon calling a “sensitive number”.

Here is the relevant part in extensions.conf:

exten =>
s,12,Set(barrfile=${FILE(/var/secure_files/callbarring.txt,0,1,l,u)})

exten => s,13,Set(passcode=${SHIFT(barrfile)})

exten => s,14,Set(barrnumbers=${SHIFT(barrfile)})

exten => s,15,GotoIf($[${REGEX(“${barrnumbers}”,${oex})} = 0]?outgoing,s,17)

exten => s,16,Authenticate(${passcode})

; Testing purposes, to not route test calls out on the PSTN.

exten => s,17,Playback(you-have-reached-a-test-number)

exten => s,18,Hangup()

; Comment the above 2 lines and uncomment the next, to enable live PSTN
operation.

;exten => s,17,Dial(SIP/${oex}@cellip)

callbarring.txt contains (passcode is changed in this example, I just used
1111 as example):

1111,^11|020|90000|09|00,

The thing is, that if I call a number that CONTAINS for example 09, it will ask for passcode, but it should only ask for passcode if it BEGINS (note the
^) on that number.

So I have tested with:

1111,^(11|020|90000|09|00),

And

1111,^11|^020|^90000|^09|^00,

But with the result that the REGEX does never match and I get to the “You have reached a test number” without authenticating, even if the number begins on 020.

How I do to anchor to the beginning of the string in REGEX?

——=_NextPart_000_001D_01D22B16.681DE430
Content-Type: text/html;
charset=”us-ascii”
Content-Transfer-Encoding: quoted-printable