Ishfaq Malik
2012-Jul-24 08:37 UTC
[asterisk-users] Finding the position of a character in a string
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} Thanks in advance 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
giovanni.v
2012-Jul-24 10:45 UTC
[asterisk-users] Finding the position of a character in a string
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) -- TeeBX VoIP communication platform (coming soon) http://code.google.com/p/teebx/ ----------------------------------------------- Lightweight++ User Friendly++ Open++
Raj Mathur (राज माथुर)
2012-Jul-24 15:04 UTC
[asterisk-users] Finding the position of a character in a string
On Tuesday 24 Jul 2012, Ishfaq Malik wrote:> 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}Worst case scenario: write a loop to iterate over each character and stop at first match. If you have ODBC installed: your SQL back-end should be able to perform this function for you. See if the dialplan function FIELDNUM can be used. There must be many more ways. Regards, -- Raj -- Raj Mathur || raju at kandalaya.org || GPG: http://otheronepercent.blogspot.com || http://kandalaya.org || CC68 It is the mind that moves || http://schizoid.in || D17F