[asterisk-users] how to strip + from the caller-ID

David Kerr David at Kerr.net
Thu Jan 14 14:46:00 CST 2010


Are you actually trying to strip off the + or are you doing it as part of
trying to check the callerid number to see if it is valid.  If the later,
then consider REGEX()... here is a snippet from my privacy manager script...

; First lookup number in asterisk DB for a Caller ID name. exten =
s,n,Set(CALLERID(name)=${IF(${DB_EXISTS(cidname/${CALLERID(num)})}?${DB_RESULT}:${CALLERID(name)})})
; Now check against whitelist. exten =
s,n,GotoIf(${DB_EXISTS(whitelist/${CALLERID(num)})}?onwhitelist) ; Not on
whitelist, check it against blacklist exten =
s,n,GotoIf(${DB_EXISTS(blacklist/${CALLERID(num)})}?onblacklist) ; Not on
blacklist either, check Caller ID number for anonymous conditions... ; If
all zeros (with or without international dialing + sign) then caller is
anonymous. exten = s,n,GotoIf($[${REGEX("^[+]?0+$" ${CALLERID(num)})} =
1]?unknown) ; If Caller ID is not a number at least 4 digits long (with or
without + sign) ; then caller is assumed to be anonymous. Alphabetic Caller
ID "numbers" ; will therefore be considered anonymous. Common numbers for
anonymous callers ; are: "asterisk, unknown, anonymous, private,
unavailable" which may be upper, lower ; or mixed case. The regular
expression catches everything non-numeric. ; If you want to permit a
specific non-numeric Caller ID "number" add it to whitelist. exten =
s,n,GotoIf($[${REGEX("^[+]?[0-9]{4\,}$" ${CALLERID(num)})} != 1]?unknown) ;
Caller ID looks good.



On Thu, Jan 14, 2010 at 9:11 AM, Danny Nicholas <danny at debsinc.com> wrote:

>  I saw something like this in another answer, but here’s an example that
> should work (would on 1.4)
>
> exten => s/_+X.,1,Set(TMPNAME=${CALLERID(name)})
>
> exten => s/_+X.,n,Set(CLEANNAME=CUT(TMPNAME|\+|2))
>
> exten => s/_+X.,n,Set(CALLERID(name)=${CLEANNAME})
>
>
>
> in my installations ${X:1} is a hit or miss proposition;  CUT is a Known
> quantity.
>
>
>  ------------------------------
>
> *From:* asterisk-users-bounces at lists.digium.com [mailto:
> asterisk-users-bounces at lists.digium.com] *On Behalf Of *Szasz Szabolcs
> *Sent:* Thursday, January 14, 2010 3:55 AM
>
> *To:* asterisk-users at lists.digium.com
> *Subject:* [asterisk-users] how to strip + from the caller-ID
>
>
>
> Hi,
>
> How can I strip + from the front of the caller ID?
> I have tried this:
> exten => s/_+X.,1,Set(CALLERID(name)=${CALLERID(name):1})
>
> But it is not working.
>
>
> Szasz Szabolcs
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100114/86aaa637/attachment.htm 


More information about the asterisk-users mailing list