[asterisk-users] Match one OR two digit extension not working as expected without using "dangerous" _. pattern (Ast 14)

Tony Mountifield tony at softins.co.uk
Fri Oct 14 08:53:49 CDT 2016


In article <CAEebyNX5JffKHFxwRJ3pSbG7YpeDLWweE=WjdmvwyzQySLSYag at mail.gmail.com>,
Jonathan H <lardconcepts at gmail.com> wrote:
> On 13 October 2016 at 13:18, Tony Mountifield <tony at softins.co.uk> wrote:
> 
> > exten => _X,1,NoOp(Matching single digit)
> > exten => _X.,1,NoOp(Matching multiple digits)
> > exten => _X!,2,SayNumber(${EXTEN})
> > exten => _X!,3,Etc..
> 
> Thanks - I appreciate the idea, but it matches more than 2 digits.
> 
> But, thanks to your info, I cobbled together something that works, and
> matches only 1 or 2 digits in what I think is the most compact way, by
> sending a 1 digit extension to the 2 digit matcher, prefixed with a 0.
> Example which works:
> 
> [extentest]
> exten => s,1,Set(TIMEOUT(digit)=1)
>     same => n,BackGround(extension)
>     same => n,WaitExten(5)
> exten => _X,1,Goto(0${EXTEN},1)
> exten => _XZ,1,SayNumber(${EXTEN})
>     same => n,Goto(s,1)
> exten => e,1,Goto(s,1)
> 
> ***HOWEVER!!!!*** Do I need to report a bug?
> 
> Either:
> 
> A: All the documentation is wrong and ". (period) Wildcard match;
> matches one or more characters" is NOT actually how Asterisk works.
> or
> B: The documentation is correct and Asterisk's "one of more character
> matching" routine is wrong
> or
> C: I've completely misunderstood what "matches one of more characters" means :)
> 
> What's the consensus? Thanks!

As I understand it, there are two different functionalities overloaded
on the operators.

1. The . in a pattern will match one or more digits, but only when
WaitExten has exited due to the digit timeout. Even if the number
being collected would match the ., it does not do so until Asterisk
decides no more digits will be entered.

2. The ! in a pattern will match zero or more digits, and will also
cause WaitExten to be satisfied as soon as it can match the pattern,
without waiting for more digits.

It's a pity that the choice between one-or-more and zero-or-more is
overloaded with wait-for-dialling-pause and match-immediately, rather
than being selectable independently. But it's been like that ever since
! was introduced, probably over 10 years ago.

Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-users mailing list