[asterisk-users] Finding the position of a character in a string

Ishfaq Malik ish at pack-net.co.uk
Wed Jul 25 09:45:21 CDT 2012


On Tue, 2012-07-24 at 12:45 +0200, giovanni.v wrote:
> Il 24/07/2012 10.37, Ishfaq Malik ha scritto:
> > It there a native asterisk dialplan function which will tell me the
> > position of a specific character in a given string?
> >
> > eg if I wanted to find what position the '@' was at in ${SIPURI}
> 
> if you are trying to extract parts from a string then look at the 
> function called 'CUT'.
> 
> verbose example:
> exten => s,1,NoOp(set DID from SIP TO header)
> exten => s,n,Set(DID_INFO=${SIP_HEADER(To)})
> exten => s,n,Set(DID_INFO=${CUT(DID_INFO,@,1)})
> exten => s,n,Set(DID_INFO=${CUT(DID_INFO,:,2)})
> exten => s,n,Goto(sip-routing,${DID_INFO},1)
> 
> 

Hi

That was exactly what I was after.

Thanks

Ish

-- 
Ishfaq Malik <ish at pack-net.co.uk>
Department: VOIP Support
Company: Packnet Limited
t: +44 (0)845 004 4994
f: +44 (0)161 660 9825
e: ish at pack-net.co.uk
w: http://www.pack-net.co.uk

Registered Address: PACKNET LIMITED, 2A ENTERPRISE HOUSE, LLOYD STREET
NORTH, MANCHESTER
SCIENCE PARK, MANCHESTER, M156SE
COMPANY REG NO. 04920552




More information about the asterisk-users mailing list