[asterisk-dev] New wildcards for pattern matching

Steve Murphy murf at parsetree.com
Wed Feb 24 19:30:02 CST 2010


On Wed, Feb 24, 2010 at 3:34 PM, Matt Riddell <lists at venturevoip.com> wrote:

> On 24/02/10 1:10 AM, Nick Lewis wrote:
> > For example using ~ as a wildcard to mean "zero or more times last char"
> > it would be possible to limit trailing chars to numeric, alphanumeric or
> > almost anything
> >
> > _123[0-9]~
> > _123[0-9a-zA-Z]~
> > _123[!-~]~
>
>
> Agree.
>
> It would also mean you could do a search and replace for _X. to _X~
>
>
OK, a final '~' meaning 0 or more of the preceding character or class. Hmmm.
Instead, would it be OK to make it 1 or more (this seems easier, as no
existing
pattern char can stand for null input).

I *don't* think it would be good to allow it in the middle, eg, "_XX8~XX",
because then you get into some sticky recursion trying to determine
if  stuff like "12888" is a match or not, as you might be tempted to absorb
all the 8's
and not leave a couple for the end of the pattern. You then back up and try
other paths,
and that's where things get complicated. And, then you can have more than
one ~ in
the pattern, and wow, you'd need rules to disambiguate.

But restricted to being at the end of a pattern, that's easier to implement.

If I can budget a little time, I might actually code this up in the new
pattern
matcher.

murf

-- 
Steve Murphy
ParseTree Corp
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20100224/10de99f3/attachment.htm 


More information about the asterisk-dev mailing list