[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
Thu Oct 13 07:18:11 CDT 2016


In article <CAEebyNV+64CsK0N5+Jwn-c1qgt9ai7E-yMu_OaMayavGQ5tfOQ at mail.gmail.com>,
Jonathan H <lardconcepts at gmail.com> wrote:
> Back to basics here. I want to match on one OR two digits.
> 
> The following two both work, but ONLY for more than one digit, which
> is not as expected from the docs (see below).
> 
> exten => _X.,1,SayNumber(${EXTEN})
> exten => _[0-9].,1,SayNumber(${EXTEN})
> 
> 
> This next one will ONLY match 2 digits, as expected, but the first two
> SHOULD match one or more, right?
> 
> exten => _XX,1,SayNumber(${EXTEN})
> 
> The following pattern works, but I thought it was "dangerous" and to
> be discouraged?
> exten => _.,1,SayNumber(${EXTEN})
> 
> So, again, if someone dials 1 and a one second delay passes, I want it to say 1.
> If someone dials 1 then another 1 within a second then I want it to be
> 11, and 111 should be invalid.
> 
> (I've Set(TIMEOUT(digit)=1) )
> 
> Yes, I can do this with multiple lines, but the docs suggest this
> should be easily do-able in 1 line, and I don't want to double the
> amount of dialplan (there'll be a few of these!).

When matching an extension being dialled, Asterisk is only concerned
about priority 1, so that's the only priority you need to double.
You should be able to use ! safely in priority 2 upwards:

exten => _X,1,NoOp(Matching single digit)
exten => _X.,1,NoOp(Matching multiple digits)
exten => _X!,2,SayNumber(${EXTEN})
exten => _X!,3,Etc..

Disclaimer: I haven't tested this.

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