[asterisk-users] Variable stripping/removing part of string

Tilghman Lesher tilghman at meg.abyt.es
Mon Apr 11 00:12:36 CDT 2011


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



More information about the asterisk-users mailing list