<span class="Apple-style-span" style="border-collapse: collapse; ">Hello,<div><br></div><div> I do not know why it did not dawn upon me to simply use the =~ operator. However it does appear to error out / not compile:</div>
<div><br></div><div>"(?i)(restricted|anonymous|private|unknown|unavailable)", i.e.</div><div><br></div><div>produces a runtime error:</div><div><br></div><div>if($hdr(From) =~ "(?i)(restricted|anonymous|private|unknown|unavailable)"){</div>
<div><br></div><div>}</div><div><br></div><div>* sending this to list.</div></span><br><div class="gmail_quote">On Thu, Sep 17, 2009 at 5:05 PM, Iñaki Baz Castillo <span dir="ltr"><<a href="mailto:ibc@aliax.net">ibc@aliax.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">El Viernes, 18 de Septiembre de 2009, Brandon Armstead escribió:<br>
<div class="im">> Hello,<br>
> I have the following pcre regex method call:<br>
><br>
> pcre_match("$hdr(From)", "(?i)^(restricted|anonymous|private|unknown|<br>
unavailable)")<br>
><br>
> to match calls that are sent without a proper ANI in a case-insensitive<br>
> manner, however it does not seem to return true for the following example<br>
> From Header:<br>
><br>
> From Header: "Unavailable"<br>
</div>> <<a href="mailto:sip%3ARestricted@192.168.47.68">sip:Restricted@192.168.47.68</a><<a href="mailto:sip%253ARestricted@192.168.47.68">sip%3ARestricted@192.168.47.68</a>><br>
<div class="im">><br>
> >;tag=gK07327e23<br>
><br>
> Any thoughts / input is appreciated, and as always thank you for your help!<br>
<br>
</div>You are using ^ symbol which means that the string MUST START by:<br>
<div class="im"> restricted|anonymous|private|unknown|unavailable<br>
<br>
</div>But your string $hdr("From") starts by "Unavailable" (*including* the<br>
quotation marks so it doesn't match).<br>
<br>
If the From URI username is enough (Restricted) you could do:<br>
<br>
pcre_match("$dU", "(?i)^(restricted|anonymous|private|unknown|<br>
unavailable)")<br>
<br>
If you need to match the Display-Name ("Unavailable") then you must add the<br>
quotation marks to the regular expression:<br>
<br>
pcre_match("$fn", "(?i)^(\")?(restricted|anonymous|private|unknown|<br>
unavailable)(\")?")<br>
<br>
Note that I use $fn rather than $hdr("From"), being $fn the From Display-Name:<br>
<a href="http://kamailio.org/dokuwiki/doku.php/pseudovariables:1.5.x#from_display_name" target="_blank">http://kamailio.org/dokuwiki/doku.php/pseudovariables:1.5.x#from_display_name</a><br>
<font color="#888888"><br>
<br>
<br>
--<br>
Iñaki Baz Castillo <<a href="mailto:ibc@aliax.net">ibc@aliax.net</a>><br>
<br>
_______________________________________________<br>
Kamailio (OpenSER) - Users mailing list<br>
<a href="mailto:Users@lists.kamailio.org">Users@lists.kamailio.org</a><br>
<a href="http://lists.kamailio.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.kamailio.org/cgi-bin/mailman/listinfo/users</a><br>
<a href="http://lists.openser-project.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.openser-project.org/cgi-bin/mailman/listinfo/users</a></font></blockquote></div><br>