Hello,

    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:

"(?i)(restricted|anonymous|private|unknown|unavailable)", i.e.

produces a runtime error:

if($hdr(From) =~ "(?i)(restricted|anonymous|private|unknown|unavailable)"){

}

* sending this to list.

On Thu, Sep 17, 2009 at 5:05 PM, Iñaki Baz Castillo <ibc@aliax.net> wrote:
El Viernes, 18 de Septiembre de 2009, Brandon Armstead escribió:
> Hello,
>     I have the following pcre regex method call:
>
>     pcre_match("$hdr(From)", "(?i)^(restricted|anonymous|private|unknown|
unavailable)")
>
> to match calls that are sent without a proper ANI in a case-insensitive
> manner, however it does not seem to return true for the following example
> From Header:
>
> From Header: "Unavailable"
> <sip:Restricted@192.168.47.68<sip%3ARestricted@192.168.47.68>
>
> >;tag=gK07327e23
>
> Any thoughts / input is appreciated, and as always thank you for your help!

You are using ^ symbol which means that the string MUST START by:
 restricted|anonymous|private|unknown|unavailable

But your string $hdr("From") starts by "Unavailable" (*including* the
quotation marks so it doesn't match).

If the From URI username is enough (Restricted) you could do:

 pcre_match("$dU", "(?i)^(restricted|anonymous|private|unknown|
 unavailable)")

If you need to match the Display-Name ("Unavailable") then you must add the
quotation marks to the regular expression:

 pcre_match("$fn", "(?i)^(\")?(restricted|anonymous|private|unknown|
 unavailable)(\")?")

Note that I use $fn rather than $hdr("From"), being $fn the From Display-Name:
 http://kamailio.org/dokuwiki/doku.php/pseudovariables:1.5.x#from_display_name



--
Iñaki Baz Castillo <ibc@aliax.net>

_______________________________________________
Kamailio (OpenSER) - Users mailing list
Users@lists.kamailio.org
http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
http://lists.openser-project.org/cgi-bin/mailman/listinfo/users