[SR-Users] String split function
Alex Balashov
abalashov at evaristesys.com
Thu Dec 29 10:18:05 CET 2016
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/
More information about the sr-users
mailing list