procmail
[Top] [All Lists]

Re: One or two string in one line

1997-09-12 22:44:05
gilles(_dot_)carmel(_at_)genomecorp(_dot_)com (Gilles Carmel) writes:
How does one write a receipe that will do following thing:  Put mail
in mailbox which as a line with two string (one and two) like:

one     two

but save mail in error-folder if the line as only the first string like:

one

(string two is missing)

Space between one and two is irrelevant, as long there are on the same
line.

I presume these lines would be located in the body of the message, and
that by "space between one and two" you mean "whitespace between one
and two".  If those assumptions are wrong then you'll need to tweak the
following recipes:

        # The 'B' tells procmail to look in the body instead of the header.
        # The second colon tells procmail to lock the mailbox with a 
        # locallockfile -- if mailbox is a directory then you don't need it.
        # The brackets in the condition contain a space and a tab.
        :0 B:
        * one[  ]*two
        mailbox

        :0 B:
        * one
        error-folder

Now, the above will match even if "one" or "two" is part of another
word (at the end in the case of "one" and at the beginning in the case
of "two").  If you don't want that then you'll need to change the
recipes to read:

        :0 B:
        * ()\<one[      ]*two\>
        mailbox

        :0 B:
        * ()\<one\>
        error-folder


Does the above all make sense?

Philip Guenther

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