[SR-Users] avps on regexps?

David Villasmil david.villasmil.work at gmail.com
Mon Mar 28 19:37:36 CEST 2022


Thanks guys,,

ended up doing:

if ($(re{uri.user}) =~ "\+" + $avp(country_code)) {
  $avp(number) = $avp(country_code) + $(fU{s.strip,3});
}

where country_code is the actual country code, which as of now it's only 2
digits, but i will have to change that to support more than that.

Regards,

David Villasmil
email: david.villasmil.work at gmail.com
phone: +34669448337


On Mon, Mar 28, 2022 at 7:14 PM Daniel-Constantin Mierla <miconda at gmail.com>
wrote:

> Hello,
>
> if I remember correctly, something similar can be achieved with dialplan
> module (might require a modparam for evaluating variables in match
> expression).
>
> There is a function to evaluate twice a string with variables, but it may
> lead to leak in some cases. I would avoid using it if not proper testing is
> done.
>
> Then, I second that KEMI can be a better option for more dynamic
> replacement needs.
>
> Cheers,
> Daniel
> On 28.03.22 16:44, Igor Olhovskiy wrote:
>
> David,
>
> Regexps in Kamailio are precompiled at script load for performance
> reasons. Really limited set of regex operations are dynamic, like
> http://www.kamailio.net/docs/modules/5.4.x/modules/textops.html#textops.f.is_present_hf_re_pv
> I'd recommend to look at KEMI if you need something dynamic.
>
> пн, 28 мар. 2022 г. в 13:04, David Villasmil <
> david.villasmil.work at gmail.com>:
>
>> Hello guys,
>>
>> Is it possible to use apvs on regexps like:
>>
>> $avp(myvar)=$(re{uri.user}{re.subst,/^\+$avp(some_var)/$avp(some_var)/});
>>
>> doesn't seem possible
>>
>> Regards,
>>
>> David Villasmil
>> email: david.villasmil.work at gmail.com
>> phone: +34669448337
>> __________________________________________________________
>> Kamailio - Users Mailing List - Non Commercial Discussions
>>   * sr-users at 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
>>
>
>
> --
> Best regards,
> Igor
>
> __________________________________________________________
> Kamailio - Users Mailing List - Non Commercial Discussions
>   * sr-users at 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
>
> --
> Daniel-Constantin Mierla -- www.asipto.comwww.twitter.com/miconda -- www.linkedin.com/in/miconda
> Kamailio Advanced Training - Online
>   March 28-31, 2022 (Europe Timezone)
>   * https://www.asipto.com/sw/kamailio-advanced-training-online/
>
> __________________________________________________________
> Kamailio - Users Mailing List - Non Commercial Discussions
>   * sr-users at 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20220328/9753daba/attachment.htm>


More information about the sr-users mailing list