How to pattern match unlimited digits but only number digits?


#1

Hi, turns out my sip client allows people to copy/paste/dial any strings so people sometimes send numbers with spaces and other characters. This might be causing problems down the line.
How can I pattern match the incoming route so only digits go through? but an unlimited number of digits.
So instead of
5533.
what would I replace the period with so that it only allows 0-9 zero or more times?
thank you!


#2

Use the asterisk ‘filter’ cmd on both inbound and outbound patterns (normalize both)

https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+Function_FILTER


#3

thank you @dicko

  1. i had seen that. But I didn’t understand it. I see I can define what characters/digits to allow, but I can’t figure out how to tell it to allow an “unlimited” number of them

  2. filter works in freepbx GUI also? if not, can I “prefilter” all numbers before they reach the outgoing route matching? or how is this applied in freepbx?

thanks!


#4

Not in the Gooey, you can pre-filter “+0123456789” but the later pattern match would then need to be _. (for the +, but asterisk will then bitch :wink: )


#5

ok, then this wont work. The freepbx system has several dozen outbound routes, each with several pattern matches. Moving all that to custom routes would probably be unworkable for the people that run the system day to day.
Hopefully I find a way to do it from the softphone.
thank you!


#6

Hi again, I am back at this as I have found no other solution on the end user side, and I reread what you wrote and think I might have misunderstood it. Can you please explain to me what you mean with this

but the later pattern match would then need to be _. (for the +, but asterisk will then bitch :wink: )

Would I the solution be something like adding the following to from-internal-custom?

[macro-dialout-trunk-predial-hook] 
exten => _+.,1,Goto(from-internal,${FILTER(0123456789*#+,${EXTEN})},1)
exten => s,n,MacroExit

I just want to leave numbers and the plus symbol. Everything else should be removed and then continue on to finding an outgoing route it matches.
Am I on the right track?
thank you!


(system) closed #7

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.