[SR-Users] s.replace Transformation and Newline

Daniel-Constantin Mierla miconda at gmail.com
Mon May 18 22:17:14 CEST 2020


Can you try with a variable:

$var(x) = "a=sendrecv\r\na=curr:qos local none";

and use it inside the s.replace transformation.

Cheers,
Daniel

On 18.05.20 19:21, Carsten Bock wrote:
> Sorry for the confusion - my initial example contained a typo. The
> right version:
>
> [...]
> $sht(sdp=>$ci) = $(rb{s.replace,a=sendrecv,a=sendrecv\r\na=curr:qos
> local none});
> [...]
> set_reply_body("$sht(sdp=>$ci)", "application/sdp");
> send_reply("200", "OK");
> [...]
>
> It works like a charm, however I'm facing one small issue:
>
> My SDP looks like this:
> [...]
> a=rtpmap:8 PCMA/8000
> a=sendrecv\r\na=curr:qos local none
> a=rtcp:34949
> [...]
>
> Thanks,
> Carsten
>
> P.S.: Never write emails between two meetings...
>
> Daniel-Constantin Mierla <miconda at gmail.com
> <mailto:miconda at gmail.com>> schrieb am Mo., 18. Mai 2020, 18:35:
>
>     Hello,
>
>     is not clear to me: so when you had it with one backslash, it was
>     the two chars '\n'  in sdp, when it was \\n was it with 2
>     backslashes (3 chars)?
>
>     Cheers,
>     Daniel
>
>     On 18.05.20 17:58, Carsten Bock wrote:
>>     Hi Daniel,
>>
>>     Unfortunately, I already had replaced that. While I had the two
>>     \\ in config, I also had two \\ in the SDP...
>>
>>     Thanks,
>>     Carsten 
>>
>>
>>     Daniel-Constantin Mierla <miconda at gmail.com
>>     <mailto:miconda at gmail.com>> schrieb am Mo., 18. Mai 2020, 17:49:
>>
>>         Hello,
>>
>>         I see you have two backslashes \\ for r and n. Have you tried
>>         with only one?
>>
>>         \\ is supposed to be \ character.
>>
>>         Cheers,
>>         Daniel
>>
>>         On 18.05.20 16:32, Carsten Bock wrote:
>>>         Hi,
>>>
>>>         I am trying the following:
>>>         - extract the message body
>>>         - replace some content
>>>         - store it in a hashtable
>>>         - send it out in a reply in later request
>>>
>>>         I do the following:
>>>
>>>         [...]
>>>         $sht(sdp=>$ci) =
>>>         $(rb{s.replace,a=sendrecv,a=sendrecv\\r\\na=curr:qos local
>>>         none});
>>>         [...]
>>>         set_reply_body("$sht(sdp=>$ci)", "application/sdp");
>>>         send_reply("200", "OK");
>>>         [...]
>>>
>>>         It works like a charm, however I'm facing one small issue:
>>>
>>>         My SDP looks like this:
>>>         [...]
>>>         a=rtpmap:8 PCMA/8000
>>>         a=sendrecv\r\na=curr:qos local none
>>>         a=rtcp:34949
>>>         [...]
>>>
>>>         It seems that s.replace is escaping characters.
>>>
>>>         Anyone any ideas?
>>>
>>>         Thanks,
>>>         Carsten
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>         $var(x) = "abababa";
>>>         $(var(x){s.replace,a,c} => "cbcbcbc"
>>>         --
>>>
>>>         Carsten Bock I CTO & Founder
>>>
>>>         ng-voice GmbH
>>>
>>>         Trostbrücke 1 I 20457 Hamburg I Germany
>>>         T +49 40 524 75 93-40 | M +49 179 2021244 I www.ng-voice.com
>>>         <http://www.ng-voice.com>
>>>
>>>         Registry Office at Local Court Hamburg, HRB 120189
>>>         Managing Directors: Dr. David Bachmann, Carsten Bock
>>>
>>>         _______________________________________________
>>>         Kamailio (SER) - Users Mailing List
>>>         sr-users at lists.kamailio.org <mailto:sr-users at lists.kamailio.org>
>>>         https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>
>>         -- 
>>         Daniel-Constantin Mierla -- www.asipto.com <http://www.asipto.com>
>>         www.twitter.com/miconda <http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda <http://www.linkedin.com/in/miconda>
>>         Funding: https://www.paypal.me/dcmierla
>>
>     -- 
>     Daniel-Constantin Mierla -- www.asipto.com <http://www.asipto.com>
>     www.twitter.com/miconda <http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda <http://www.linkedin.com/in/miconda>
>     Funding: https://www.paypal.me/dcmierla
>
-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Funding: https://www.paypal.me/dcmierla

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20200518/a5371b1c/attachment.html>


More information about the sr-users mailing list