[OpenSIPS-Users] An obstacle with using variables in regular expression

Donat Zenichev donat.zenichev at gmail.com
Wed Feb 19 13:40:49 EST 2020


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20200219/8808bd9c/attachment.html>


More information about the Users mailing list