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.

Content-Type: text/plain;
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 =>

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

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

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


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:




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?

Content-Type: text/html;
Content-Transfer-Encoding: quoted-printable