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]
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

Reply via email to