procmail
[Top] [All Lists]

Re: scanning for text within the first few lines of the body?

2002-03-29 15:48:27
PSE-L(_at_)mail(_dot_)professional(_dot_)org (Professional Software 
Engineering) writes:
I'd just as soon that they didn't need to spawn processes any more often 
than necessary, so I'm trying to figure out the lowest overhead way to 
restrict a search of the body text to just the first few lines.

Few == ?  Three?  Three, but only if they contain no non-whitespace
characters?

(Come on, Sean, you know how important it is to be specific!)


Optimally, I'd like to be able to check whether a text is the first thing 
in the body.  Specifically, I'm looking for _properly formatted_ majordomo 
approval commands (which are submitted to the list address, not the central 
majordomo address), which should bypass the filter set.

Any suggestions?

Currently, the condition is simply:

:0B
* ^Approved:[  ]+[^    ]+$
{
      do whatever
}

This doesn't consider whether the text is the first non-whitespace in tbe 
whole body, or limit the search to the first few lines.

To allow at most three lines containing no non-whitespace characters before
the 'Approved' line you would write something like:

        :0 B
        * ^^([  ]*$([   ]*$([   ]*$)?)?)?Approved:[     ]+[^    ]+$
        {
                do whatever
        }

Note the '^^' to anchor against the beginning of the body.


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>