[Asterisk-Users] pattern matching problems

Adam Goryachev mailinglists at websitemanagers.com.au
Tue Aug 31 04:47:23 MST 2004


On Tue, 2004-08-31 at 21:42, Atif Rasheed wrote:
> this is from my extensions.conf, the first three patterns are for
> toll-free numbers, and fourth pattern is for other numbers, where an AGI
> is called for authentication. 
> now when I dial 011448000664327 if falls into the fourth pattern, where
> as it should be matched by the first pattern. Any suggestions
> 
> 1 - exten => _01144800XXXXXXX,1,Dial(${MAG}/${EXTEN:3},45,tT)
> 2 - exten => _01144808XXXXXXX,1,Dial(${MAG}/${EXTEN:3},45,tT)
> 3 - exten => _01144500XXXXXXX,1,Dial(${MAG}/${EXTEN:3},45,tT)
> 
> 4 - exten => _011.,1,AGI(iax.agi)
> 4 - exten => _011.,2,Dial(${MAG}/${EXTEN:3},45,tT)
> 4 - exten => _011.,103,playback(no-service)

This is because asterisk is 'lazy'. It will not take the "first"
matching extension, nor will it take the most specific matching
extension, instead, it will take the least specific extension. This
means, regardless of the number, if it matches 011* then it will always
take that option. The only way to acheive what you want (AFAIK) is like
this:

[blah]
include => foo
include => bar
[foo]
exten => _01144800XXXXXXX,1,Dial(${MAG}/${EXTEN:3},45,tT)
exten => _01144808XXXXXXX,1,Dial(${MAG/${EXTEN:3},45,tT)
exten => _01144500XXXXXXX,1,Dial(${MAG}/${EXTEN:3},45,tT)
[bar]
exten => _011.,1,AGI(iax.agi)
exten => _011.,2,Dial(${MAG}/${EXTEN:3},45,tT)
exten => _011.,103,playback(no-service)

This will force asterisk to look/match extensions in foo before it
attempts to look/match extensions in bar.

Hope this helps (and it is actually correct, try it and see)

Regards,
Adam




More information about the asterisk-users mailing list