[SR-Users] Text transformations s.select and newline char
Daniel-Constantin Mierla
miconda at gmail.com
Thu May 20 13:28:20 CEST 2021
Hello,
the separator has to be a single character as documented:
*
https://www.kamailio.org/wiki/cookbooks/5.5.x/transformations#sselect_index_separator
It does not support variables.
Looking at the code, it also does not support escaped characters,
probably this feature can be useful to introduce.
Cheers,
Daniel
On 17.05.21 12:03, Martin Nyström wrote:
>
> Hello,
>
>
>
> I am simply trying to parse a SDP body, read it line by line and save
> the line into a variable for further processing. It seems when using a
> newline \n as the delimiter it breaks down with errors. How should I
> treat this issue and properly managed the newline as delimiter?
>
>
>
> May 17 12:00:00 ip-10-120-120-12 kamailio[12878]: 0(12878) ERROR: pv
> [pv_trans.c:2326]: tr_parse_string(): invalid select transformation:
> select,$var(i),$var(delimeter)}!!
>
> May 17 12:00:00 ip-10-120-120-12 kamailio[12878]: 0(12878) ERROR:
> <core> [core/pvapi.c:1717]: tr_lookup(): error parsing
> [{s.select,$var(i),$var(delimeter)}]
>
>
>
>
>
> Block extracted from .cfg
>
>
>
> sdp_get("$avp(sdp)");
>
> $avp(lines) = $(avp(sdp){line.count});
>
> $var(delimeter) = "\n";
>
>
>
> $var(i) = 0;
>
> while($var(i) < $avp(lines)) {
>
>
>
> # This works
>
> xlog("L_INFO", "==> Position $var(i):
> $(avp(sdp){s.select,$var(i),\n}) \n");
>
>
>
> # This fails
>
> $var(l1) = $(avp(sdp){s.select,$var(i),$var(delimeter)});
>
>
>
> # This fails
>
> $var(l2) = $(avp(sdp){s.select,$var(i),\n});
>
>
>
> # This fails
>
> $var(l3) = $(avp(sdp){s.select,$var(i),\\n});
>
>
>
> # Supposed to do something funny with the $var(line) here
>
>
>
> $var(i) = $var(i) + 1;
>
>
>
> }
>
>
>
>
>
>
>
> /M
>
>
> __________________________________________________________
> Kamailio - Users Mailing List - Non Commercial Discussions
> * sr-users at lists.kamailio.org
> Important: keep the mailing list in the recipients, do not reply only to the sender!
> Edit mailing list options or unsubscribe:
> * https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Kamailio Advanced Training - Online
May 17-20, 2021 (Europe Timezone) - June 7-10, 2021 (America Timezone)
* https://www.asipto.com/sw/kamailio-advanced-training-online/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20210520/d81d4825/attachment.htm>
More information about the sr-users
mailing list