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.68sip%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_nam...