Hi , Can someone explain me what is \1 and \3 doing in the subst expression ?
Input : From: <sip:anonymous@10.211.160.168
;tag=41008079_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_78DD
subst('/^From:(.*)10.211.160.168(.*)>(.*)/From:\110.211.160.174>\3/ig'); Output : From: <sip:anonymous@10.211.160.174
;tag=41008079_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_78DD
Regards, Mahesh.b
They are references to groups in the regex match. The groups are in parenthesis. Whatever is matched by group 1 and 3 will be included in the substitution.
https://regexr.com/ and https://regex101.com/ are both good sites for building and explaining regexes.
Thanks John for the Reply.
So if i understand properly : group 1 is here <sip:anonymous@ group 2 is empty group 3 is ;tag=41008079_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_78DD
the previous expression is working for IPv4.
Now for IPv6
Input : From: sip:anonymous@ [2008:abcd:1234:2260:208:5dff:fe93:5b65];tag=42006C96_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_8092 subst('/^From:(.*)[2008:abcd:1234:2260:208:5dff:fe93:5b65](.*)>(.*)/From:\1[2008:abcd:1234:2260:20c:29ff:fe9a:b9cb]>\3/ig'); Output : From: sip:anonymous@[2008:abcd:1234:2260:208:5dff:fe93:5b6[2008:abcd:1234:2260:20c:29ff:fe9a:b9cb];tag=42006C96_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_8092 //what is going wrong here?
Here group 1 is <sip:anonymous@ group 2 is empty group 3 is ;tag=42006C96_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_8092
what mistake am i making for IPv6 ? if you see the output.
Regards, Mahesh.b
On Mon, Jul 2, 2018 at 6:54 PM John Petrini jpetrini@coredial.com wrote:
They are references to groups in the regex match. The groups are in parenthesis. Whatever is matched by group 1 and 3 will be included in the substitution.
https://regexr.com/ and https://regex101.com/ are both good sites for building and explaining regexes. _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
I think i found the reason, it needs a \ before [ , could you please tell me whats the syntax to put the replacement expression in this page?
[image: image.png]
Regards, Mahesh.B
On Mon, Jul 2, 2018 at 7:10 PM mahesh b mahesh.b.2487@gmail.com wrote:
Thanks John for the Reply.
So if i understand properly : group 1 is here <sip:anonymous@ group 2 is empty group 3 is ;tag=41008079_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_78DD
the previous expression is working for IPv4.
Now for IPv6
Input : From: sip:anonymous@ [2008:abcd:1234:2260:208:5dff:fe93:5b65];tag=42006C96_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_8092
subst('/^From:(.*)[2008:abcd:1234:2260:208:5dff:fe93:5b65](.*)>(.*)/From:\1[2008:abcd:1234:2260:20c:29ff:fe9a:b9cb]>\3/ig'); Output : From: sip:anonymous@[2008:abcd:1234:2260:208:5dff:fe93:5b6[2008:abcd:1234:2260:20c:29ff:fe9a:b9cb];tag=42006C96_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_8092 //what is going wrong here?
Here group 1 is <sip:anonymous@ group 2 is empty group 3 is ;tag=42006C96_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_8092
what mistake am i making for IPv6 ? if you see the output.
Regards, Mahesh.b
On Mon, Jul 2, 2018 at 6:54 PM John Petrini jpetrini@coredial.com wrote:
They are references to groups in the regex match. The groups are in parenthesis. Whatever is matched by group 1 and 3 will be included in the substitution.
https://regexr.com/ and https://regex101.com/ are both good sites for building and explaining regexes. _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Your first group is matching From: <sip:anonymous@[2008:abcd:1234:2260:208:5dff:fe93:5b6 but it looks like you want it to only match <sip:anonymous@. Try escaping the brackets, the regex engine is interpreting them as a list instead of matching the literal "[]" characters.
subst('/^From:(.*)[2008:abcd:1234:2260:208:5dff:fe93:5b65]( .*)>(.*)/From:\1[2008:abcd:1234:2260:20c:29ff:fe9a:b9cb]>\3/ig');
John Petrini Platforms Engineer
[image: Call CoreDial] 215.297.4400 x 232 <215-297-4400> [image: Call CoreDial] www.coredial.com https://coredial.com/ [image: CoreDial] 751 Arbor Way, Hillcrest I, Suite 150 Blue Bell, PA 19422 https://www.google.com/maps/place/CoreDial,+LLC/@40.140902,-75.2878857,17z/data=!3m1!4b1!4m5!3m4!1s0x89c6bc587f1cfd47:0x4c79d505f2ee580b!8m2!3d40.140902!4d-75.285697 The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
On Mon, Jul 2, 2018 at 9:40 AM, mahesh b mahesh.b.2487@gmail.com wrote:
Thanks John for the Reply.
So if i understand properly : group 1 is here <sip:anonymous@ group 2 is empty group 3 is ;tag=41008079_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_78DD
the previous expression is working for IPv4.
Now for IPv6
Input : From: sip:anonymous@[2008:abcd: 1234:2260:208:5dff:fe93:5b65];tag=42006C96_nab_FFFF_isp_ FFFF_cco_FFFF_igo_FFFF_mgt_8092 subst('/^From:(.*)[2008:abcd:1234:2260:208:5dff:fe93:5b65]( .*)>(.*)/From:\1[2008:abcd:1234:2260:20c:29ff:fe9a:b9cb]>\3/ig'); Output : From: sip:anonymous@[2008:abcd: 1234:2260:208:5dff:fe93:5b6[2008:abcd:1234:2260:20c:29ff: fe9a:b9cb];tag=42006C96_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_8092 //what is going wrong here?
Here group 1 is <sip:anonymous@ group 2 is empty group 3 is ;tag=42006C96_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_8092
what mistake am i making for IPv6 ? if you see the output.
Regards, Mahesh.b
On Mon, Jul 2, 2018 at 6:54 PM John Petrini jpetrini@coredial.com wrote:
They are references to groups in the regex match. The groups are in parenthesis. Whatever is matched by group 1 and 3 will be included in the substitution.
https://regexr.com/ and https://regex101.com/ are both good sites for building and explaining regexes. _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
it is subst('/ ^From:(.*)[2008:abcd:1234:2260:208:5dff:fe93:5b65](.*)>(.*)/From:\1[2008:abcd:1234:2260:20c:29ff:fe9a:b9cb]>\3 /ig');
Thank you!
On Mon, Jul 2, 2018 at 7:52 PM John Petrini jpetrini@coredial.com wrote:
Your first group is matching From: <sip:anonymous@[2008:abcd:1234:2260:208:5dff:fe93:5b6 but it looks like you want it to only match <sip:anonymous@. Try escaping the brackets, the regex engine is interpreting them as a list instead of matching the literal "[]" characters.
subst('/^From:(.*)[2008:abcd:1234:2260:208:5dff:fe93:5b65](.*)>(.*)/From:\1[2008:abcd:1234:2260:20c:29ff:fe9a:b9cb]>\3/ig');
John Petrini Platforms Engineer
[image: Call CoreDial] 215.297.4400 x 232 <215-297-4400> [image: Call CoreDial] www.coredial.com https://coredial.com/ [image: CoreDial] 751 Arbor Way, Hillcrest I, Suite 150 Blue Bell, PA 19422 https://www.google.com/maps/place/CoreDial,+LLC/@40.140902,-75.2878857,17z/data=!3m1!4b1!4m5!3m4!1s0x89c6bc587f1cfd47:0x4c79d505f2ee580b!8m2!3d40.140902!4d-75.285697 The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
On Mon, Jul 2, 2018 at 9:40 AM, mahesh b mahesh.b.2487@gmail.com wrote:
Thanks John for the Reply.
So if i understand properly : group 1 is here <sip:anonymous@ group 2 is empty group 3 is ;tag=41008079_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_78DD
the previous expression is working for IPv4.
Now for IPv6
Input : From: sip:anonymous@ [2008:abcd:1234:2260:208:5dff:fe93:5b65];tag=42006C96_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_8092
subst('/^From:(.*)[2008:abcd:1234:2260:208:5dff:fe93:5b65](.*)>(.*)/From:\1[2008:abcd:1234:2260:20c:29ff:fe9a:b9cb]>\3/ig'); Output : From: sip:anonymous@[2008:abcd:1234:2260:208:5dff:fe93:5b6[2008:abcd:1234:2260:20c:29ff:fe9a:b9cb];tag=42006C96_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_8092 //what is going wrong here?
Here group 1 is <sip:anonymous@ group 2 is empty group 3 is ;tag=42006C96_nab_FFFF_isp_FFFF_cco_FFFF_igo_FFFF_mgt_8092
what mistake am i making for IPv6 ? if you see the output.
Regards, Mahesh.b
On Mon, Jul 2, 2018 at 6:54 PM John Petrini jpetrini@coredial.com wrote:
They are references to groups in the regex match. The groups are in parenthesis. Whatever is matched by group 1 and 3 will be included in the substitution.
https://regexr.com/ and https://regex101.com/ are both good sites for building and explaining regexes. _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users