1
votes

My sip client is sending numbers dialed with some strange characters in the place of spaces.

E.g 011▒237▒1140141

How do i remove the characters in an asterisk dialplan before dialing out the extension?

3

3 Answers

1
votes

I fixed the issue with the FILTER command in the dialplan:

exten => _X.,1,Set(CALLERID(dnid)=${FILTER(0-9,${CALLERID(dnid)})})
0
votes

A quick (but not flawless) workaround could be this:

exten => s,1,Set(strangeID=${CALLERID(number)})
exten => s,2,Set(strangeID_splited=${CUT(strangeID,▒,1-3&5-7&9-16)})
exten => s,3,Dial(SIP/stangeID_splited)

I'm assuming the strange character is other than , so you can declare it on your dialplan and the numbers are always the same lenght and position, so you can tell Asterisk which positions are the undesirable chars.

Otherwise, you could make an AGI script to eliminate those characters, I know is not the fanciest way, but it'll work for sure.

Hope that helps.

0
votes

You can use FILTER function. Yes, you cna regexp replace too, but that is much more complex.

localhost*CLI> core show function FILTER

  -= Info about function 'FILTER' =- 

[Synopsis]
Filter the string to include only the allowed characters 

[Description]
Permits all characters listed in <allowed-chars>,  filtering all others outs.
In addition to literally listing the characters,  you may also use ranges
of characters (delimited by a '-'
Hexadecimal characters started with a '\x'(i.e. \x20)
Octal characters started with a '\0' (i.e. \040)
Also '\t','\n' and '\r' are recognized.
NOTE: If you want the '-' character it needs to be prefixed with a  '\'

[Syntax]
FILTER(allowed-chars,string)