How to Change alphabet ANI into Numaric ANI

we want to append in start four digits with every incoming number and we want to display only four digits on those calls whose comes with alphabets. We set the following rules

exten => _X!,1,Set(CALLERID(num)=1666${CALLERID(num)})
exten => _X!,1,GotoIf($["${CALLERID(num)}" = “Unknown”]?changeCLI)
exten => _X!,s(changeCLI),Set(CALLERID(num)=1666)

these rules works fine for numeric cli but if we get abcd in cli then calls goes with ‘1666abcd’ and our carrier rejected that call because they only accept numeric cli. We just want to send 1666 instead of 1666abcd.

thanks in advance and your prompt reply will be highly appreciated.

There are at least two errors in that dialplan fragment, so I can’t see how it works. There may be one more, but that depends on what you intended to write.

As a general outline of what you need to do, use a regular expression match, or even a wildcard “ex-girlfriend” match (I think current versions allow these), then use the normal ${variable-or-funcion:n:m} notation.

[quote=“david55”]There are at least two errors in that dialplan fragment, so I can’t see how it works. There may be one more, but that depends on what you intended to write.

As a general outline of what you need to do, use a regular expression match, or even a wildcard “ex-girlfriend” match (I think current versions allow these), then use the normal ${variable-or-funcion:n:m} notation.[/quote]

Can you please write the exact dialplan here. I will execute and update you the status. I hope you understand my issue exactly.