procmail
[Top] [All Lists]

Re: ?s about the "^^" regexp

1997-09-16 15:12:15
Simeon(_dot_)Nevel(_at_)Schwab(_dot_)COM writes:
I had the following in my .procmailrc trying to trap
some spam.

#Body consists entirely of html code
:0B:
* $[   ]*<html>
spamtrap

Also, the leading dollarsign will be interpreted by procmail as request
to perform variable expansion on the rest of the line and reparse, so the
actual regexp used was just "[  ]*<html>", something which'll match any
message which has "<html>" in the body.

...
I guess the condition test is applied to *each* line of the body.

The condition test is applied to the entire body.  If you want to limit
it to match only against the beginning of the body, you have to say so
using the ^^ token, as you discovered.  A simple line anchor (^ or $)
just says that there must be a newline (or the beginning or end of the
area being searched) at that particular point in the text being
matched.


Would the following:

#Body consists entirely of html code
:0B:
* ^^[  ]*<html>
spamtrap

trap spam where the *very* first line of the body started with
"<html>"?

Yes.


What, exactly, does "Anchor the expression at the very start of the search
area..." mean when applied to "B" flag tests?

The B flag causes the search area to be the body of the message.  The
"very start of the search area" would be the beginning of the body.


Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>