[SR-Users] Find Values in User part of Diversion URI

Lewis Hutchinson lewis.hutchinson at missionlabs.co.uk
Mon May 30 10:13:19 CEST 2022


Excellent thanks I knew there would be a simple way that I was missing, just couldn't get my head into it late on Friday.

Thanks Henning

Lewis

From: Henning Westerholt <hw at gilawa.com>
Sent: 28 May 2022 11:13
To: Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org>
Cc: Lewis Hutchinson <lewis.hutchinson at missionlabs.co.uk>
Subject: RE: Find Values in User part of Diversion URI

Hello,

for the first question, you could use textops

https://www.kamailio.org/docs/modules/devel/modules/textops.html#textops.f.search_hf<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.kamailio.org%2Fdocs%2Fmodules%2Fdevel%2Fmodules%2Ftextops.html%23textops.f.search_hf&data=05%7C01%7Clewis.hutchinson%40missionlabs.co.uk%7Cf47cb26808b1498bd55a08da4092b0d9%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637893297062348266%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=QlRI%2FB0nDkQ2azOhiHxAyqCWobDeVm54B%2BMkuATgmXI%3D&reserved=0>

or just cfg regular expression match on the PV together with a transformation

if ($(hdr(Diversion){uri.user}) ~= "...")

to see if the header field contains the value.

For the second question, there is not function right now that is the opposite of the is.numeric. You could use some regular expression replace transformation for example to achieve a similar result, I think.

Cheers,

Henning

--
Henning Westerholt - https://skalatan.de/blog/<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fskalatan.de%2Fblog%2F&data=05%7C01%7Clewis.hutchinson%40missionlabs.co.uk%7Cf47cb26808b1498bd55a08da4092b0d9%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637893297062348266%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=FNRiwOSNsekorZH6qv8rJDr6v6rqbbKSv3Tk3a0azU0%3D&reserved=0>
Kamailio services - https://gilawa.com<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgilawa.com%2F&data=05%7C01%7Clewis.hutchinson%40missionlabs.co.uk%7Cf47cb26808b1498bd55a08da4092b0d9%7C97c26f550a7a4661bd8f7b43b50d3f2b%7C0%7C0%7C637893297062348266%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=oXyFjzn7mNHoa9xHpy8AH%2FuPyKixjalyKQa%2FAVeOLyE%3D&reserved=0>

From: sr-users <sr-users-bounces at lists.kamailio.org<mailto:sr-users-bounces at lists.kamailio.org>> On Behalf Of Lewis Hutchinson
Sent: Friday, May 27, 2022 3:53 PM
To: sr-users at lists.kamailio.org<mailto:sr-users at lists.kamailio.org>
Subject: [SR-Users] Find Values in User part of Diversion URI

Sorry if this is a super basic ask but I can't seem to work it out, I have got a work around but for my own sanity wanted to post the question on here.

In Kamailio Native 5.5.2

I want to be able to look into this field $(di{uri.user}) and "find" or see if it "contains" a value

i.e Diversion: "TEST" sip:112233445566 at xxx.xxx.xxx.xxx;user=phone;

find 234

or

contains 234

I know how to do this in in KEMI Python but for the life of me cant get my head around it in Native.

2ndly is there an opposite to {s.numeric} Removes all non-numeric parts of string.

I want the ability to strip all numeric parts.

Keep us the good work.


Lewis

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20220530/b05fe9af/attachment.htm>


More information about the sr-users mailing list