Eric,

Thanks; of course, this is also an option.  However, setting up a separate 
context for this type of thing with several identical Goto statements also 
strikes me as inelegant, even if it is less so. 

-- Nathan

-----Original Message-----
From: asterisk-users-boun...@lists.digium.com 
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Eric Wieling
Sent: Thursday, March 28, 2013 8:33 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] Pattern matching repeating digits

You are correct, it is stupid 8-)  

exten => 233,1,Goto(dial-out,${EXTEN},1)
exten => 255,1,Goto(dial-out,${EXTEN},1)

[dial-out]

exten => _XXX,1,DoStuff()
exten => _XXX,n,AndMoreStuff()
exten => _XXX,n,Dial(something)
exten => _XXX,n,Hangup

-----Original Message-----
From: asterisk-users-boun...@lists.digium.com 
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Nathan Anderson
Sent: Wednesday, March 27, 2013 2:18 AM
To: 'asterisk-users@lists.digium.com'
Subject: [asterisk-users] Pattern matching repeating digits

'lo, all,

Is there some (possibly undocumented?) way that I can pattern-match on a 
specified number of repeating digits?  (Something similar to regular 
expressions' {})

Here's an example: let's say I have a string of things that need to be done for 
both extensions 233 and 255.  I can either...

A) Repeat the exact same code for both extensions, like so:

exten => 233,1,DoStuff()
exten => 233,n,AndMoreStuff()
exten => 233,n,Dial(something)

exten => 255,1,DoStuff()
exten => 255,n,AndMoreStuff()
exten => 255,n,Dial(something)

...which is stupid, or...

B) I can attempt code reuse for similar cases (a Good Thing[tm]), and make as 
specific of a match as possible, like so:

exten => _2[35][35],1,DoStuff()
exten => _2[35][35],n,AndMoreStuff()
exten => _2[35][35],n,Dial(something)

...but this will not only match 233 and 255, but 235 and 253 as well.

It'd be nice if there was a substitute character that meant "a character that 
is exactly the same as the preceding one"; for example, if R was meant to 
represent such a concept, then this would do what I want:

exten => _2[35]R,1,DoStuff()
exten => _2[35]R,n,AndMoreStuff()
exten => _2[35]R,n,Dial(something)

You could even do crazy things like chain them together (this would match 23333 
and 25555 and nothing else);

exten => _2[35]RRR,1,DoStuff()
exten => _2[35]RRR,n,AndMoreStuff()
exten => _2[35]RRR,n,Dial(something)

Am I missing something or does this really not exist?

Thanks,

--
Nathan Anderson
First Step Internet, LLC
nath...@fsr.com

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to 
Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to