<div dir="ltr">Hi,<br><br>I'm trying to capture and substitute the host IP of contact header using the subst_hf but it's not working as expected. I tested my regex in a tester and it works fine there but not in the Kamailio config.<br><br>Regex: @(.+?)><br><br>Substitution: @PUBLIC_IP:5060><br><br>Three contact headers that I'm trying to match;<br><br>Contact:<sip:0065*<a href="http://7766@172.16.1.217:5060">7766@172.16.1.217:5060</a>>;methods="INVITE,ACK,BYE,CANCEL,OPTIONS,INFO,MESSAGE,SUBSCRIBE,NOTIFY,PRACK,UPDATE,REFER"<br><br>Contact: <sip:0065*<a href="mailto:7788@172.16.1.216">7788@172.16.1.216</a>;transport=udp>;expires=3600;reg-id=1;+sip.instance="<urn:uuid:03660bc5-bb70-4784-8ac5-000413B108BA>"<br><br>Contact: <sip:0925*<a href="http://0007@172.16.1.218:5060">0007@172.16.1.218:5060</a>><br><br>Outcome I'm expecting for the three contact headers;<br><br>Contact:<sip:0065*7766@PUBLIC_IP:5060>;methods="INVITE,ACK,BYE,CANCEL,OPTIONS,INFO,MESSAGE,SUBSCRIBE,NOTIFY,PRACK,UPDATE,REFER"<br><br>Contact: <sip:0065*7788@PUBLIC_IP:5060>;expires=3600;reg-id=1;+sip.instance="<urn:uuid:03660bc5-bb70-4784-8ac5-000413B108BA>"<br><br>Contact: <sip:0925*0007@PUBLIC_IP:5060><br><br>This regex in Kamailio works fine for the first and third contact header but for the second contact header it matches all the way to the end of the contact header excluding the quote (") sign. I've tried so many other combinations [like @(.+?)>;? ] of regex but nothing seems to work.<br><br>Is there a way to accomplish this with one regex?<br><br>Thanks,<br>Sal<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 25 Nov 2022 at 16:10, Salvinder Parhar <<a href="mailto:salvinder.parhar09@gmail.com">salvinder.parhar09@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I'm trying to capture and substitute the host IP of contact header using the subst_hf but it's not working as expected. I tested my regex in a tester and it works fine there but not in Kamailio config.</div><div><br></div><div><b>Regex:</b> @(.+?)></div><div><br></div><div><b>Substitution:</b> <a class="gmail_plusreply" id="m_2192040369922161123plusReplyChip-0">@PUBLIC_IP:5060></a></div><div><br></div><div><b>Three contact headers that I'm trying to match;</b></div><div><br></div><div>Contact:<sip:0065*<a href="http://7766@199.48.100.166:5060" target="_blank">7766@199.48.100.166:5060</a>>;methods="INVITE,ACK,BYE,CANCEL,OPTIONS,INFO,MESSAGE,SUBSCRIBE,NOTIFY,PRACK,UPDATE,REFER"<br><br>Contact: <sip:0065*<a href="mailto:7788@172.16.1.216" target="_blank">7788@172.16.1.216</a>;transport=udp>;expires=3600;reg-id=1;+sip.instance="<urn:uuid:03660bc5-bb70-4784-8ac5-000413B108BA>"<br><br>Contact: <sip:0925*<a href="http://0007@199.48.100.166:5060" target="_blank">0007@199.48.100.166:5060</a>><br></div><div><br></div><div><b>Outcome I'm expecting for the three contact headers;</b></div><div><br></div><div>Contact:<sip:0065*7766<a class="gmail_plusreply" id="m_2192040369922161123gmail-plusReplyChip-0"><b>@PUBLIC_IP:5060></b></a>;methods="INVITE,ACK,BYE,CANCEL,OPTIONS,INFO,MESSAGE,SUBSCRIBE,NOTIFY,PRACK,UPDATE,REFER"<br><br>Contact: <sip:0065*7788<a class="gmail_plusreply" id="m_2192040369922161123gmail-plusReplyChip-0"><b>@PUBLIC_IP:5060></b></a>;expires=3600;reg-id=1;+sip.instance="<urn:uuid:03660bc5-bb70-4784-8ac5-000413B108BA>"<br><br>Contact: <sip:0925*0007<a class="gmail_plusreply" id="m_2192040369922161123gmail-plusReplyChip-0"><b>@PUBLIC_IP:5060></b></a><br></div><div><br></div><div>This regex in Kamailio works fine for the first and third contact header but for the second contact header it matches all the way to the end of the contact header excluding the quote (") sign. I've tried so many other combinations [like <b>@(.+?)>;?</b> ] of regex but nothing seems to work.</div><div><br></div>Is there a way to accomplish this with one regex?<div><br></div><div>Thanks,</div><div>Sal</div><div><br></div><div><br></div><div><br><a class="gmail_plusreply"><b><br></b></a></div><div><a class="gmail_plusreply"><b><br></b></a></div><div><br></div><div><br></div></div>
</blockquote></div>