<div dir="ltr"><div>Hi <span style="color:rgb(0,0,0)">Răzvan!</span></div><div><span style="color:rgb(0,0,0)">Thank you that you spent your time on this.</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">Your way worked out and the check now works as intended.</span></div><div><span style="color:rgb(0,0,0)">I can't thank you enough, really appreciate this.</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">Have a nice day!<br></span></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 19, 2020 at 4:24 PM Răzvan Crainea <<a href="mailto:razvan@opensips.org">razvan@opensips.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi, Donat!<br>
<br>
Your code is checking the variable with the "^$var(each)" <br>
string/literal, the variable is not expanded within the quotes (like it <br>
is done in php).<br>
In order to fix this, you should do something like:<br>
$var(regex) = "^" + $var(each);<br>
if ($rU ~= $var(regex))<br>
<br>
Best regards,<br>
Răzvan<br>
<br>
On 2/19/20 3:40 PM, Donat Zenichev wrote:<br>
> Hi OpenSIPS community!<br>
> I've come across one small obstacle, when trying to use pseudo variables<br>
> or attribute value pairs in regular expression.<br>
> <br>
> I believe my mistake should be quite simple.<br>
> <br>
> Regular expression is used in a condition:<br>
> if ( $rU =~ "^$var(each)" )<br>
> <br>
> $var(each) - is a string variable, not integer. It contains certain <br>
> prefix, like "44".<br>
> <br>
> For some reason OpenSIPS script is not able to get through this check <br>
> properly.<br>
> But, in case I hardcode something like this:<br>
> if ( $rU =~ "^44" )<br>
> then it passes a check as needed.<br>
> <br>
> To my shame, I spent several hours trying to solve this in different <br>
> ways, but without any success.<br>
> <br>
> I think that the problem consists of extra quotes appearing when <br>
> $var(each) comes into play.<br>
> So I have first quoting defined in a condition, they wrap regular exp: <br>
> ^$var(each)<br>
> And when $var(each) is defined in a condition, it gets quotes too, since <br>
> it's a string.<br>
> <br>
> Of course I can use some other way to run this check, for example with <br>
> help of regex module.<br>
> But my curiosity doesn't give me any chance to set this case aside.<br>
> <br>
> Any advice is appreciated!<br>
> <br>
> -- <br>
> <br>
> Best regards,<br>
> Donat Zenichev<br>
> <br>
> <br>
> _______________________________________________<br>
> Users mailing list<br>
> <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
> <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
> <br>
<br>
-- <br>
Răzvan Crainea<br>
OpenSIPS Core Developer<br>
<a href="http://www.opensips-solutions.com" rel="noreferrer" target="_blank">http://www.opensips-solutions.com</a><br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr"><font style="background-color:rgb(255,255,255)" color="#0b5394">Best regards,<br></font></div><div dir="ltr"><font style="background-color:rgb(255,255,255)" color="#0b5394">Donat Zenichev<br><br></font></div></div></div></div></div></div></div></div>