Tim Panton
2006-Sep-05 03:21 UTC
[asterisk-users] How to manipulate a plus in a phone number
I'm hoping someone has solved this problem before, because I'm stuck! I get phone numbers from a database into my dial plan via AGI. Some of the numbers use the + sign to denote an 'international' number. I need to re-write these numbers into a format my IAX provider can deal with (ie a us style international number starting with 011). So +3115162728 -> 00113115162728 Unfortunately all the ways I've tried to manipulate the number in the dialplan fail because the + is an operator and I can't get the parser to treat it as a 'normal' string. Here are some things I have tried to use to detect the + exten => 1,n,set(INNAT=${ATELNO:\+}) and exten => 1,n,set(INNAT=${REGEX("^\+","${ATELNO}")}) and exten => 1,n,set(INNAT=${FIELDQTY(+,${ATELNO})}) None of them work..... I know I could get the database to do the rewriting, but then I've got database code that is IAX provider dependent, which I'd like to avoid. Anyone got any neat tricks?? Tim Panton www.mexuar.com
Doug Lytle
2006-Sep-05 04:04 UTC
[asterisk-users] How to manipulate a plus in a phone number
Tim Panton wrote:> exten => 1,n,set(INNAT=${REGEX("^\+","${ATELNO}")}) >Just a grab in the dark, have you tried using single quotes instead of the double? Doug -- Ben Franklin quote: "Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety."
Stefan Tichy
2006-Sep-05 05:21 UTC
[asterisk-users] Re: How to manipulate a plus in a phone number
On Tue, Sep 05, 2006 at 11:21:43AM +0100, Tim Panton wrote:> exten => 1,n,set(INNAT=${REGEX("^\+","${ATELNO}")})exten => 1,n,Set(PLUS=\\+) exten => 1,n,set(INNAT=${REGEX("^${PLUS}" ${ATELNO})}) If it is an extension, this should work too exten => _+.,1,Goto(011${EXTEN:1},1) -- Stefan Tichy <asterisk@pi4tel.de>
Tim Panton
2006-Sep-05 06:07 UTC
[asterisk-users] Re: How to manipulate a plus in a phone number
On 5 Sep 2006, at 13:21, Stefan Tichy wrote:> On Tue, Sep 05, 2006 at 11:21:43AM +0100, Tim Panton wrote: >> exten => 1,n,set(INNAT=${REGEX("^\+","${ATELNO}")}) > > exten => 1,n,Set(PLUS=\\+) > exten => 1,n,set(INNAT=${REGEX("^${PLUS}" ${ATELNO})}) > >That worked, Thanks! Tim. Tim Panton www.mexuar.com
At 03:21 AM 9/5/2006, you wrote:>exten => 1,n,set(INNAT=${FIELDQTY(+,${ATELNO})}) > >None of them work.....This is what I do: exten => s,n,gotoif($["${EXTEN:0:2}" = "+1"]?fixcid:okcid) exten => s,n(fixcid), set(xxx=${EXTEN:0:2}) exten => s,n(okcid), noop() Ira