procmail
[Top] [All Lists]

Re: need help with a regular expression

2001-03-02 23:57:58
Dallman Ross <dman(_at_)nomotek(_dot_)com> writes:
From: Philip Guenther <guenther(_at_)gac(_dot_)edu>
The real answer is that there is no general way to match exactly N
occurences of a character except by writing out N of them.

     !!!!|####|\^\^\^\^
...
<complicated and not really effective attempt to do the above>
...
I'm too tired to check whether my syntax is right.  I might have goofed
somewhere - not sure, and it's not tested.

I can think of (at least) one algorithmic flaw: suppose the string found is

      !####

That would flunk our test for four in a row like the first char,
even though it is composed only of chars from the sought set
and even though there *are* four in a row of one char from that set.
Oh, well.  One could always use a recursive INCLUDERC to loop . . . .

You can indeed write the test using a recursive INCLUDERC, but that is
actually the _only_ way to do it in pure procmail (no outside programs).
There are only two ways to loop/iterate in procmail: the internal process
of matching a regexp, and recursive INCLUDERCs.  Since regexps can't
do this (that can be proved), a recusive INCLUDERC is the only way that
really works.


I wouldn't have bothered, but something gets me going whenever someone
says there's "no way."  :-)

I should have said "there's no way using just true regexps (finite-state
machines)".  True regularal expressions, such as the ones implemented
by procmail, cannot "count" occurences of non-fixed strings.


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

<Prev in Thread] Current Thread [Next in Thread>
  • Re: need help with a regular expression, Philip Guenther <=