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

2012-07-25 Thread Ishfaq Malik
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 
Department: VOIP Support
Company: Packnet Limited
t: +44 (0)845 004 4994
f: +44 (0)161 660 9825
e: i...@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


--
_
-- 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


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

2012-07-24 Thread Raj Mathur (राज माथुर)
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  || r...@kandalaya.org   || GPG:
http://otheronepercent.blogspot.com || http://kandalaya.org || CC68
It is the mind that moves   || http://schizoid.in   || D17F

--
_
-- 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


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

2012-07-24 Thread giovanni.v

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++

--
_
-- 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


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

2012-07-24 Thread Ishfaq Malik
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 
Department: VOIP Support
Company: Packnet Limited
t: +44 (0)845 004 4994
f: +44 (0)161 660 9825
e: i...@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


--
_
-- 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