[asterisk-users] Normalizing called numbers

Johann Hoehn johann.hoehn at ecommerce.com
Fri May 28 20:46:32 CDT 2010


Rémi Philippe wrote:
> Hi,
> I'm working on my dial plan and I'd like to parse all dialed numbers
> to convert them to the format I want.
> For example if someone dials 0112345678 or 0033112345678 I would like
> to convert it to +33112345678 and then match the number to my exten =>
> +33XXXXXXXX statements.
>
> Is this possible with asterisk? I tried different ways (using _., s,
> ...) but I can't seem to get that working right...
>
> Thanks for your help,
>
> Remi
>
>   

Assuming you are using a version with AEL, this can be done in a cleaner 
way with the pattern part of a switch statement:

switch(${CALLERID(num)}) {
    pattern 011XXXXXXX:
        CALLERID(num)="+3311XXXXXXX";
        break;
    pattern 003311XXXXXXX:
        CALLERID(num)="+3311XXXXXXX";
        break;
    default:
        LOG(NOTICE, Callerid ${CALLERID(num)} not normalized);
        break;
  }


You will likely want to put this into a macro and tweak it further based 
other patterns that you encounter.

--johann



More information about the asterisk-users mailing list