[asterisk-dev] Better pattern matching

Leif Madsen leif.madsen at asteriskdocs.org
Thu Aug 2 09:26:09 CDT 2007

On Thursday 02 August 2007 09:13:51 am Steve Murphy wrote:
> I like the idea of using different notations to allow different
> pattern matching algorithms.
> But, if we want Asterisk to step up into a higher volume use arena,
> we absolutely have to re-do the extension pattern matching algorithm
> to avoid linear searching. There are ramifications, as I said before,
> to things like realtime, where multiple database reads need to be done
> to select a proper extension.
> I was about to go on and on about scoring matches, but the regex libs
> will only give us a set of patterns that match the given string. These
> patterns can be assigned scores when they are compiled. I think. I'll
> have to check on that.
> At least, I hope the scoring is based on the patterns, not on the string
> they match.

While we're talking about this, I'd like to make two suggestions.

1) If we add new pattern matching functionality, it'd be a good idea to have 
an option of turning it on and off. Some people have a hard enough time 
understanding the current system, and maybe some people don't need anything 
other than a basic system, so a setting like the following at the top of the 
extensions.conf file would be useful:


2) The ability to have an alias or shortcut to say, "use the previous pattern 
match", similar to the 'n' priority (or rather, the 's' priority), so I can 
write a complex pattern match, BUT only have to write it on the first 

exten => nancy|jim|james,1,NoOp()
exten => p,n,Verbose(1|My current EXTEN is ${EXTEN})
exten => p,n,Playback(silence/1&tt-weasels)
exten => p,n,Hangup()

Leif Madsen.

More information about the asterisk-dev mailing list