Asterisk dialplan patterns


#1

Hi Team,

I am using Asterisk 13.16.0
According to the documentation, symbols “.” and “!” in CID/DID dialplan patterns are valid only at the end of a pattern. However, is there any way to mask “zero or more characters” at the beginning of a pattern?

Real case: my server has multiple trunks, and differens VoIP providers send CID differently. Assuming that the local phone number is 123 4567 and zone code is 495, a CID may potentially come in any of the following formats:

  • 4951234567
  • 84951234567
  • +74951234567

It would be nice to use a single pattern like _.4951234567, but “.” is ignored at the beginning.
Is there any way to avoid creation of multiple patterns?
Your comments are appreciated.


#2

Re-write the CID to a canonical form, before matching.


#3

What do you mean by a “canonical form”? CID in any of the above formats can be received from the ISP. I would like to “catch” any of these formats with a pattern before manipulating with it.


#4

A suitable canonical form would be the full international number.


#5

I understand. However, if an ISP sends a CID in a non-canonical format, I need to catch it before converting to E.164.

And the question above sounds “Is there any way to catch all the numbers listed with a single pattern”?


#6

Only by explicit regular expression checks using ExecIf or GotoIf.


#7

Good point - will check it