[SR-Users] String split function
Grant Bagdasarian
gb at cm.nl
Thu Dec 29 10:23:51 CET 2016
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 at lists.sip-router.org] On Behalf Of Alex Balashov
Sent: donderdag 29 december 2016 10:18
To: Kamailio (SER) - Users Mailing List <sr-users at 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 at lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
More information about the sr-users
mailing list