How to use a local variable as regex string

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

How to use a local variable as regex string

Eli Hayun
Hi
I am trying to add my dial plan and I did the following:

[

$var(dp_local) = "^sip:9.{3}@";

if(uri=~$var(dp_local)) {
        ... act as a local call
}

]

I am getting a syntax error because the sip parser expect to get a
string . I do not want to use hard-code string. Is there a way to do
what I want?

Best regards

Eli

   


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: How to use a local variable as regex string

Brett Nemeroff
Use the dialplan module for this.. it's *great* :)
-Brett



On Thu, Jun 11, 2009 at 7:52 AM, Eli Hayun <[hidden email]> wrote:
Hi
I am trying to add my dial plan and I did the following:

[

$var(dp_local) = "^sip:9.{3}@";

if(uri=~$var(dp_local)) {
       ... act as a local call
}

]

I am getting a syntax error because the sip parser expect to get a
string . I do not want to use hard-code string. Is there a way to do
what I want?

Best regards

Eli




_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: How to use a local variable as regex string

Bogdan-Andrei Iancu
In reply to this post by Eli Hayun
Hi Eli,

you have two solutions:

1) static approach:
       if(uri=~"^sip:9.{3}@" ) {}

2) dynamic approach - use dialplan module
http://www.opensips.org/html/docs/modules/1.5.x/dialplan.html to store
the regexp in DB.

Regards,
Bogdan

Eli Hayun wrote:

> Hi
> I am trying to add my dial plan and I did the following:
>
> [
>
> $var(dp_local) = "^sip:9.{3}@";
>
> if(uri=~$var(dp_local)) {
> ... act as a local call
> }
>
> ]
>
> I am getting a syntax error because the sip parser expect to get a
> string . I do not want to use hard-code string. Is there a way to do
> what I want?
>
> Best regards
>
> Eli
>
>    
>
>
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: How to use a local variable as regex string

Bogdan-Andrei Iancu
the  rewritehostport()  does not accept variables, but you can do the
same as:

    $rd = $var(myhostaddress);

http://www.opensips.org/Resources/DocsCoreVar15#toc55

Regards,
Bogdan

Eli Hayun wrote:

> Thanks
> That's solve my dial plan problem but what if I want to use the variable
> in my routine. such as:
>
>  rewritehostport($var(myhostaddress));
>
> it gives me the same error.
>
> Regards
> Eli
>
> On Thu, 2009-06-11 at 17:16 +0300, Bogdan-Andrei Iancu wrote:
>  
>> Hi Eli,
>>
>> you have two solutions:
>>
>> 1) static approach:
>>        if(uri=~"^sip:9.{3}@" ) {}
>>
>> 2) dynamic approach - use dialplan module
>> http://www.opensips.org/html/docs/modules/1.5.x/dialplan.html to store
>> the regexp in DB.
>>
>> Regards,
>> Bogdan
>>
>> Eli Hayun wrote:
>>    
>>> Hi
>>> I am trying to add my dial plan and I did the following:
>>>
>>> [
>>>
>>> $var(dp_local) = "^sip:9.{3}@";
>>>
>>> if(uri=~$var(dp_local)) {
>>> ... act as a local call
>>> }
>>>
>>> ]
>>>
>>> I am getting a syntax error because the sip parser expect to get a
>>> string . I do not want to use hard-code string. Is there a way to do
>>> what I want?
>>>
>>> Best regards
>>>
>>> Eli
>>>
>>>    
>>>
>>>
>>> _______________________________________________
>>> 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