magnus.b at inputinterior.se
2011-Apr-11 05:07 UTC
[asterisk-users] Variable stripping/removing part of string
Hi! I try to get rid of some part of CALLERID(name) but I cant realy figure out a way to do it. For example: CALLERID(name) = "Martela (fax)" I am just looking for the part before ? (? in my case ?Martela?. I can?t serch for ? ?, could be many ? ?, but only one ? (?, thought i could do something like: exten => 0424449631,n,NoOp(${CUT(CALLERID(name),\(,1):0:-1}) But that gave me ?Martela ? so my way of doing it is wrong. Any that can tell me what I am doing wrong or have any better suggestion howto do it? /Magnus -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110411/41add524/attachment.htm>
Tilghman Lesher
2011-Apr-11 05:12 UTC
[asterisk-users] Variable stripping/removing part of string
On Monday 11 April 2011 00:07:08 magnus.b at inputinterior.se wrote:> Hi! > > I try to get rid of some part of CALLERID(name) but I cant realy figure > out a way to do it. For example: CALLERID(name) = "Martela (fax)" I am > just looking for the part before ? (? in my case ?Martela?. I can?t > serch for ? ?, could be many ? ?, but only one ? (?, thought i could do > something like: > > exten => 0424449631,n,NoOp(${CUT(CALLERID(name),\(,1):0:-1}) > > But that gave me ?Martela ? so my way of doing it is wrong. > Any that can tell me what I am doing wrong or have any better suggestion > howto do it?You're almost there. The issue is that CUT uses 1-based offsets, not 0-based offsets, so: exten => 0424449631,n,NoOp(${CUT(CALLERID(name),\(,2):0:-1}) -- Tilghman
magnus.b at inputinterior.se
2011-Apr-11 07:56 UTC
[asterisk-users] Variable stripping/removing part of string
It was a 1.8 but then we started to do a lot of development (ooh323) so today it is Asterisk SVN-may-ooh323_ipv6_direct_rtp-r311741MS-/trunk. Can hardly se that we have done any changes that would cause my "problem". -----Ursprungligt meddelande----- From: Tilghman Lesher Sent: Monday, April 11, 2011 9:36 AM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [asterisk-users] Variable stripping/removing part of string On Monday 11 April 2011 00:25:35 magnus.b at inputinterior.se wrote:> Now i am lost. > exten => 0424449631,n,NoOp(${CALLERID(name)}) > exten => 0424449631,n,NoOp(${CUT(CALLERID(name),\(,2):0:-1}) > -- Executing [0424449631 at fax.inputinterior.se:4] NoOp("OOH323/Avaya2-8", > "Martela (fax)") in new stack > -- Executing [0424449631 at fax.inputinterior.se:5] NoOp("OOH323/Avaya2-8", > "fax)") in new stack > But i am looking for the part before " (", in my case: "Martela"Oh, sorry. You were right before, then. As far as the :0:-1 nomenclature, what version of Asterisk are you using? It was not supported before 1.4. -- Tilghman -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Jeroen Eeuwes
2011-Apr-11 10:09 UTC
[asterisk-users] Variable stripping/removing part of string
Hi Magnus,> exten => 0424449631,n,NoOp(${CUT(CALLERID(name),\(,1):0:-1}) > > But that gave me ?Martela ? so my way of doing it is wrong. > Any that can tell me what I am doing wrong or have any better suggestion > howto do it?I think you are not able to do it in one step. Can you try something like this: exten => 0424449631,n,Set(TESTING=${CUT(CALLERID(name),\(,1)}) exten => 0424449631,n,NoOp(${TESTING:0:-1}) Best regards, Jeroen Eeuwes
magnus.b at inputinterior.se
2011-Apr-11 10:58 UTC
[asterisk-users] Variable stripping/removing part of string
U were right, breaking it into two lines work. exten => 0424449631,n,NoOp(${CALLERID(name)}) exten => 0424449631,n,Set(name=${CUT(CALLERID(name),\(,1)}) exten => 0424449631,n,NoOp(${name:0:-1}) -- Executing [0424449631 at fax.inputinterior.se:4] NoOp("OOH323/Avaya2-150", "Martela (fax)") in new stack -- Executing [0424449631 at fax.inputinterior.se:5] Set("OOH323/Avaya2-150", "name=Martela ") in new stack -- Executing [0424449631 at fax.inputinterior.se:6] NoOp("OOH323/Avaya2-150", "Martela") in new stack But still, dont understand why u cant do it on one line, but u cant always understand everything. Anyway, thx for pointing me to the correct direction. -----Ursprungligt meddelande----- From: Jeroen Eeuwes Sent: Monday, April 11, 2011 12:09 PM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [asterisk-users] Variable stripping/removing part of string Hi Magnus,> exten => 0424449631,n,NoOp(${CUT(CALLERID(name),\(,1):0:-1}) > > But that gave me ?Martela ? so my way of doing it is wrong. > Any that can tell me what I am doing wrong or have any better suggestion > howto do it?I think you are not able to do it in one step. Can you try something like this: exten => 0424449631,n,Set(TESTING=${CUT(CALLERID(name),\(,1)}) exten => 0424449631,n,NoOp(${TESTING:0:-1}) Best regards, Jeroen Eeuwes -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to Asterisk? Join us for a live introductory webinar every Thurs: http://www.asterisk.org/hello asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users
Chad Wallace
2011-Apr-12 01:27 UTC
[asterisk-users] Variable stripping/removing part of string
On Mon, 11 Apr 2011 12:58:39 +0200 <magnus.b at inputinterior.se> wrote:> U were right, breaking it into two lines work. > > exten => 0424449631,n,NoOp(${CALLERID(name)}) > exten => 0424449631,n,Set(name=${CUT(CALLERID(name),\(,1)}) > exten => 0424449631,n,NoOp(${name:0:-1}) > -- Executing [0424449631 at fax.inputinterior.se:4] > NoOp("OOH323/Avaya2-150", "Martela (fax)") in new stack > -- Executing [0424449631 at fax.inputinterior.se:5] > Set("OOH323/Avaya2-150", "name=Martela ") in new stack > -- Executing [0424449631 at fax.inputinterior.se:6] > NoOp("OOH323/Avaya2-150", "Martela") in new stack > > But still, dont understand why u cant do it on one line, but u cant > always understand everything. > Anyway, thx for pointing me to the correct direction.Just a guess... try this: exten => 0424449631,n,NoOp(${${CUT(CALLERID(name),\(,1)}:0:-1})> -----Ursprungligt meddelande----- > From: Jeroen Eeuwes > Sent: Monday, April 11, 2011 12:09 PM > To: Asterisk Users Mailing List - Non-Commercial Discussion > Subject: Re: [asterisk-users] Variable stripping/removing part of > string > > Hi Magnus, > > > exten => 0424449631,n,NoOp(${CUT(CALLERID(name),\(,1):0:-1}) > > > > But that gave me ?Martela ? so my way of doing it is wrong. > > Any that can tell me what I am doing wrong or have any better > > suggestion howto do it? > > I think you are not able to do it in one step. Can you try something > like this: > > exten => 0424449631,n,Set(TESTING=${CUT(CALLERID(name),\(,1)}) > exten => 0424449631,n,NoOp(${TESTING:0:-1})
magnus.b at inputinterior.se
2011-Apr-12 04:44 UTC
[asterisk-users] Variable stripping/removing part of string
Weired result: exten => 0424449631,n,NoOp(${CALLERID(name)}) exten => 0424449631,n,NoOp(${${CUT(CALLERID(name),\(,1)}:0:-1}) -- Executing [0424449631 at fax.inputinterior.se:4] NoOp("OOH323/Avaya2-248", "Martela (fax)") in new stack -- Executing [0424449631 at fax.inputinterior.se:5] NoOp("OOH323/Avaya2-248", "") in new stack Now I understand even less. (But it was a nice try). -----Ursprungligt meddelande----- From: Chad Wallace Sent: Tuesday, April 12, 2011 3:27 AM To: asterisk-users at lists.digium.com Subject: Re: [asterisk-users] Variable stripping/removing part of string On Mon, 11 Apr 2011 12:58:39 +0200 <magnus.b at inputinterior.se> wrote:> U were right, breaking it into two lines work. > > exten => 0424449631,n,NoOp(${CALLERID(name)}) > exten => 0424449631,n,Set(name=${CUT(CALLERID(name),\(,1)}) > exten => 0424449631,n,NoOp(${name:0:-1}) > -- Executing [0424449631 at fax.inputinterior.se:4] > NoOp("OOH323/Avaya2-150", "Martela (fax)") in new stack > -- Executing [0424449631 at fax.inputinterior.se:5] > Set("OOH323/Avaya2-150", "name=Martela ") in new stack > -- Executing [0424449631 at fax.inputinterior.se:6] > NoOp("OOH323/Avaya2-150", "Martela") in new stack > > But still, dont understand why u cant do it on one line, but u cant > always understand everything. > Anyway, thx for pointing me to the correct direction.Just a guess... try this: exten => 0424449631,n,NoOp(${${CUT(CALLERID(name),\(,1)}:0:-1})