[Asterisk-Users] Removing "-" (Dash) from Dialed Numbers
Scott Miller
scoscmil at imap.iu.edu
Mon Sep 26 12:06:46 MST 2005
That solutions kind of works, but only for phone numbers that are in the
format xxx-xxx-xxxx. The records I am receiving from LDAP vary
significantly because the user can control their entry. So I can receiving
mostly the following formats.
(xxx) xxx-xxxx
xxx xxx-xxxx
xxx-xxx-xxxx
Ideally, I'd like a function that would remove all characters but the
numbers, but I haven't found a way to do that. If I were more fluent in C,
I might write a module to do it. Instead, I added some extensions to try to
compensate for the common formats, and it looks like this.
[app-clean-ldap]
exten => _XXX-XXX-XXXX,1,SetVar(AreaCode=${EXTEN:0:3})
exten => _XXX-XXX-XXXX,2,SetVar(Prefix=${EXTEN:4:3})
exten => _XXX-XXX-XXXX,3,SetVar(Suffix=${EXTEN:8:4})
exten =>
_XXX-XXX-XXXX,4,Goto(from-internal,91${AreaCode}${Prefix}${Suffix},1)
exten => _(XXX) XXX-XXXX,1,SetVar(AreaCode=${EXTEN:1:4})
exten => _(XXX) XXX-XXXX,2,SetVar(Prefix=${EXTEN:5:3})
exten => _(XXX) XXX-XXXX,3,SetVar(Suffix=${EXTEN:9:4})
exten => _(XXX)
XXX-XXXX,4,Goto(from-internal,${AreaCode}${Prefix}${Suffix},1)
exten => _XXX XXX-XXXX,1,SetVar(AreaCode=${EXTEN:0:3})
exten => _XXX XXX-XXXX,2,SetVar(Prefix=${EXTEN:4:3})
exten => _XXX XXX-XXXX,3,SetVar(Suffix=${EXTEN:8:4})
exten => _XXX
XXX-XXXX,4,Goto(from-internal,91${AreaCode}${Prefix}${Suffix},1)
My only problem now is that I can't pattern match a space character in the
last two sections. I was able use a period as a wildcard to match the
space, but that returns unexpected results if someone has more than one
character in there. Does anyone know how to match a space character in the
dial plan? Help is always appreciated.
Thanks,
Scott Miller
_____
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Colin Anderson
Sent: Friday, September 23, 2005 2:47 PM
To: 'Asterisk Users Mailing List - Non-Commercial Discussion'
Subject: RE: [Asterisk-Users] Removing "-" (Dash) from Dialed Numbers
Not very elegant, but:
exten => 1,1,SetVar(MyNumber=780-555-1212)
exten => 1,2,SetVar(AreaCode=${MyNumber:3:3})
exten => 1,3,SetVar(Prefix=${MyNumber:5:7})
exten => 1,4,SetVar(Suffix=${MyNumber:8:11})
exten => 1,5,Dial(ZAP/g0/1${AreaCode}${Prefix}${Suffix})
hth
-----Original Message-----
From: Scott Miller [mailto:scoscmil at imap.iu.edu]
Sent: Friday, September 23, 2005 1:22 PM
To: asterisk-users at lists.digium.com
Subject: [Asterisk-Users] Removing "-" (Dash) from Dialed Numbers
I am trying to enable dial-by-email by using LDAPget to query an Active
Directory server. I've got it retrieving the phone number fine.
Unforunately, the numbers stored in active directory are either in the
format: (xxx) xxx-xxxx or xxx-xxx-xxxx. Is there any way to parse
characters out of the dialed phone number so that I only end up with digits
(remove spaces, parenthesis and dashes)? From there, my outbound routes
can take care of where to send the call.
Help is always appreciated! :-)
Thank you,
Scott Miller
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20050926/98b1bf0c/attachment.htm
More information about the asterisk-users
mailing list