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

Liviu Chircu liviu at opensips.org
Wed Feb 19 14:22:41 EST 2020


On 19.02.2020 15:40, Donat Zenichev wrote:
> 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.

Hi Donat,

Indeed, that is a syntax limitation.  What's interesting, is that if you 
were to do:

     $var(regex) = "^" + $var(each);
     if ($rU =~ $var(regex))

... you would be surprised to find out that it would actually work!

Regards,

-- 
Liviu Chircu
www.twitter.com/liviuchircu | www.opensips-solutions.com

OpenSIPS Summit, Amsterdam, May 2020
   www.opensips.org/events
OpenSIPS Bootcamp, Miami, March 2020
   www.opensips.org/training




More information about the Users mailing list