https://www.kamailio.org/wiki/cookbooks/5.2.x/transformations#lineat_pos
Try {line.at,pos}

On Tue, May 18, 2021, 08:09 Martin Nyström <martin.nystrom@connectel.se> 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@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