Hey, Donat!
You're welcome :D
But you should actually thank liviuc, as he wrote the correct snippet -
I used the wrong operator ~= instead of the correct one =~ :)
Cheers!
Răzvan
On 2/19/20 4:37 PM, Donat Zenichev wrote:
Hi Răzvan!
Thank you that you spent your time on this.
Your way worked out and the check now works as intended.
I can't thank you enough, really appreciate this.
Have a nice day!
On Wed, Feb 19, 2020 at 4:24 PM Răzvan Crainea <[email protected]
<mailto:[email protected]>> wrote:
Hi, Donat!
Your code is checking the variable with the "^$var(each)"
string/literal, the variable is not expanded within the quotes (like it
is done in php).
In order to fix this, you should do something like:
$var(regex) = "^" + $var(each);
if ($rU ~= $var(regex))
Best regards,
Răzvan
On 2/19/20 3:40 PM, Donat Zenichev wrote:
> Hi OpenSIPS community!
> I've come across one small obstacle, when trying to use pseudo
variables
> or attribute value pairs in regular expression.
>
> I believe my mistake should be quite simple.
>
> Regular expression is used in a condition:
> if ( $rU =~ "^$var(each)" )
>
> $var(each) - is a string variable, not integer. It contains certain
> prefix, like "44".
>
> For some reason OpenSIPS script is not able to get through this
check
> properly.
> But, in case I hardcode something like this:
> if ( $rU =~ "^44" )
> then it passes a check as needed.
>
> To my shame, I spent several hours trying to solve this in different
> ways, but without any success.
>
> I think that the problem consists of extra quotes appearing when
> $var(each) comes into play.
> So I have first quoting defined in a condition, they wrap regular
exp:
> ^$var(each)
> And when $var(each) is defined in a condition, it gets quotes
too, since
> it's a string.
>
> Of course I can use some other way to run this check, for example
with
> help of regex module.
> But my curiosity doesn't give me any chance to set this case aside.
>
> Any advice is appreciated!
>
> --
>
> Best regards,
> Donat Zenichev
>
>
> _______________________________________________
> Users mailing list
> [email protected] <mailto:[email protected]>
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
--
Răzvan Crainea
OpenSIPS Core Developer
http://www.opensips-solutions.com
_______________________________________________
Users mailing list
[email protected] <mailto:[email protected]>
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
--
Best regards,
Donat Zenichev
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
--
Răzvan Crainea
OpenSIPS Core Developer
http://www.opensips-solutions.com
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users