[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openser-users
Subject:    Re: [SR-Users] String split function
From:       Grant Bagdasarian <gb () cm ! nl>
Date:       2016-12-29 9:23:51
Message-ID: d69b533e77944a7c9504ffc71a13b8a4 () CM-EX-V01 ! cm ! local
[Download RAW message or body]

Hi Alex,

Thank you for the answer.
I'll do it with the string transformations.

Regards,

Grant

-----Original Message-----
From: sr-users [mailto:sr-users-bounces@lists.sip-router.org] On Behalf Of Alex \
                Balashov
Sent: donderdag 29 december 2016 10:18
To: Kamailio (SER) - Users Mailing List <sr-users@lists.sip-router.org>
Subject: Re: [SR-Users] String split function

Hi Grant,

On Thu, Dec 29, 2016 at 09:12:05AM +0000, Grant Bagdasarian wrote:

> Hi,
> 
> Is there a string split function built into Kamailio for use in the 
> cfg script?  I'd like to split a string of key/value pairs inside the 
> cfg script.  For example: Key1=Value1;Key2=Value2; First split on ; 
> Then on =

Alas, there is nothing like that. Such a function would have to return an array or \
arraylike structure, and outside of AVPs, there are no array primitives in native \
Kamailio route script.

The best you can do is:

   $var(i) = 0;

   while(defined $(var(str){s.select,$var(i),DELIMITER})) {
      $var(token) = $(var(str){s.select,$var(i),DELIMITER});
      $var(i) = $var(i) + 1;
   }

-- Alex

--
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 (direct) / +1-800-250-5920 (toll-free)
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list \
sr-users@lists.sip-router.org \
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users \
_______________________________________________ SIP Express Router (SER) and Kamailio \
(OpenSER) - sr-users mailing list sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic