我的SIP客户端正在发送带有一些奇怪字符的号码,而不是空格。
E.g 011▒237▒1140141
如何在拨出分机号码之前删除星号拨号方案中的▒
个字符?
答案 0 :(得分:1)
您可以使用FILTER功能。是的,你也可以regexp替换,但这要复杂得多。
本地主机* CLI>核心展示功能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)
答案 1 :(得分:0)
快速(但不完美)的解决方法可能是:
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)
我假设奇怪的字符不是▒
,所以你可以在你的拨号方案上声明它,并且数字总是相同的长度和位置,所以你可以告诉Asterisk哪些位置是不受欢迎的字符。
否则,您可以创建一个AGI脚本来消除这些字符,我知道这不是最好的方式,但它肯定会起作用。
希望有所帮助。
答案 2 :(得分:0)
我使用拨号方案中的FILTER
命令解决了问题:
exten => _X.,1,Set(CALLERID(dnid)=${FILTER(0-9,${CALLERID(dnid)})})