procmail
[Top] [All Lists]

Re: stripping char from an email subject line and storing it as a variable

2002-06-11 12:13:17
I need for procmail to read only the first few characters (left to right) 
of an email subject line and store it as a variable. I already know
how to save the parsed data as a variable. What I need help with
is how, given the following subject line

Subject:ref215 2002-06-10 14:33:34

I can "grab" just the 'ref215' characters before the single space. 
BTW, 'ref###' if a reference number that will change (increment) 
with each incoming email. Also, I can change the blank space 
after 'ref###' with any character if that would make the recipe
argument simpler.

Try something like this:

  :0
  * ^Subject: *\/ref[^ ]+
  { REFNUM=$MATCH }

everything that matches after \/ is stored in the MATCH variable, and
we're matching ref followed by non-space characters.  (Take a look at
man procmailrc for more about \/).

The action stored the matched value into the REFNUM variable.

There is no delivery so procmail will process any later recipes and
there's no need for a 'c' flag here.

Hope that helps,
Martin
-- 
Martin McCarthy                 /</    http://procmail.non-prophet.org
    `Procmail Companion'        \>\
     Addison Wesley             /</                  PGP key available
_______________________________________________
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>