procmail
[Top] [All Lists]

Re: Suggestion for Enhancement; B, H, ... and D

2002-02-19 21:39:28
"David W. Tamkin" <dattier(_at_)ripco(_dot_)com> writes:
...
| | You can do ranges using multiple nested paren expressions with '?', so
| | instead of writing, for example, "a{3,7}" you would write:
| | aaa(a(a(aa?)?)?)?

It was either that or aaa(((aa?)?a)?a)? but I can never remember which.

The former.  Why?  Well...

Imagine we have the string "aaaab" and we trying matching it with the
two regexps:
        aaa(a(a(aa?)?)?)?b
and     aaa(((aa?)?a)?a)?b


Once procmail has matched the first three 'a' and sees that next character
is an 'a', it has to decide how to match it.  With the first regexp
        aaa(a(a(aa?)?)?)?b
            ^
that 'a' has to be matched by the one marked with a caret.  On the other
hand, with the second regexp
        aaa(((aa?)?a)?a)?b
              ^^   ^  ^
that next 'a' could be matched by any of the four remaining 'a's in
the regexp, depending on how many more 'a's there are after it.  If,
as if the case here, there are no more 'a's, then the last ones marked
with a caret is the 'real' match, but it won't know that until it tries
to match the next character.

Does that help?


Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail