Page 166 - Asterisk™: The Future of Telephony
P. 166

After the underscore, you can use one or more of the following characters.
               X
                   Matches any single digit from 0 to 9.
               Z
                   Matches any single digit from 1 to 9.
               N
                   Matches any single digit from 2 to 9.
               [15-7]
                   Matches a single digit from the range of digits specified. In this case, the pattern
                   matches a single 1, 5, 6, or 7.
               . (period)
                   Wildcard match; matches one or more characters, no matter what they are.

                              If you’re not careful, wildcard matches can make your dialplans do
                              things you’re not expecting (like matching built-in extensions such
                              as i or h). You should use the wildcard match in a pattern only after
                              you’ve matched as many other digits as possible. For example, the
                              following pattern match should probably never be used:
                                  _.
                              In fact, Asterisk will warn you if you try to use it. Instead, use this
                              one, if at all possible:
                                  _X.

               ! (bang)
                   Wildcard match; matches zero or more characters, no matter what they are.
               To use pattern matching in your dialplan, simply put the pattern in the place of the
               extension name (or number):
                   exten => _NXX,1,Playback(auth-thankyou)
               In this example, the pattern matches any three-digit extension from 200 through 999
               (the N matches any digit between 2 and 9, and each X matches a digit between 0 and 9).
               That is to say, if a caller dialed any three-digit extension between 200 and 999 in this
               context, he would hear the sound file auth-thankyou.gsm.
               One other important thing to know about pattern matching is that if Asterisk finds
               more than one pattern that matches the dialed extension, it will use the most specific
               one (going from left to right). Say you had defined the following two patterns, and a
               caller dialed 555-1212:
                   exten => _555XXXX,1,Playback(digits/1)
                   exten => _55512XX,1,Playback(digits/2)
               In this case the second extension would be selected, because it is more specific.



               138 | Chapter 5: Dialplan Basics
   161   162   163   164   165   166   167   168   169   170   171