Modify FROM header with REG EXP

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Modify FROM header with REG EXP

Spady#7
This post was updated on .
Hi all, I am trying to do a weird thing regarding modify FROM header of INVITE. Let me explain:

This is a snippet of INVITE that i am trying to modify:

FROM: "Name Surname"<sip:0522375542@domain.local;user=phone>;epid=6BEB47B1B9;tag=898892e6e7.

What I want to achieve is:

FROM: "Name Surname"<sip:532542@domain.local;user=phone>;epid=6BEB47B1B9;tag=898892e6e7.

So as you can see i need to modify ONLY a portion of FROM's user name. I need to strip "05223755", leave "42" and add "5325" prefix.

Is there a way to do that?

I am trying with "subst" of textops module but i suppose it only works for R-URI.

uac_replace_from does not give the possibility to use regular expression.

Any idea?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Modify FROM header with REG EXP

Bogdan-Andrei Iancu-2
Hello,

You have to look into the uac_replace_from() function from the uac
module (http://www.opensips.org/html/docs/modules/1.9.x/uac.html#id250475).

First take the FROM username into a variable ($fU), apply changes over
it (you may use string transformations -
http://www.opensips.org/Resources/DocsCoreTran19#toc1 - if you have a
fix number of digits to strip, or a regexp based transformation -
http://www.opensips.org/Resources/DocsCoreTran19#toc68).

Then use the uac_replace_from to change the username part of FROM URI

Regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com


On 04/10/2013 05:13 PM, spady wrote:

> Hi all, I am trying to do a weird thing regarding modify FROM header of
> INVITE. Let me explain:
>
> This is a snippet of INVITE that i am trying to modify:
>
> *FROM: "Name
> Surname"<sip:[hidden email];user=phone>;epid=6BEB47B1B9;tag=898892e6e7.*
>
> What I want to achieve is:
>
> FROM: "Name
> Surname"<sip:&lt;b>532542*@domain.local;user=phone>;epid=6BEB47B1B9;tag=898892e6e7.
>
> So as you can see i need to modify ONLY a portion of FROM's user name. I
> need to strip "05223755", leave "42" and add "5325" prefix.
>
> Is there a way to do that?
>
> I am trying with "subst" of textops module but i suppose it only works for
> R-URI.
>
> uac_replace_from does not give the possibility to use regular expression.
>
> Any idea?
>
> Thanks.
>
>
>
>
> --
> View this message in context: http://opensips-open-sip-server.1449251.n2.nabble.com/Modify-FROM-header-with-REG-EXP-tp7585772.html
> Sent from the OpenSIPS - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users