Sebastian Nielsen
2016-Oct-20 19:10 UTC
[asterisk-users] Problems with REGEXP - anchor string to beginning
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? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20161020/837bc1f4/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 6298 bytes Desc: S/MIME Cryptographic Signature URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20161020/837bc1f4/attachment.bin>