procmail
[Top] [All Lists]

Re: How do i save to forwards to separate files according to subject

2000-09-28 09:23:41
Poohba wrote:
What I have so far is:

:0
  * ^From.*gerber
  * ^Subject:(.*:)? *\/[^ :]+\<.*
  {
   SUBJECT=$MATCH

I read recently that matches are stingy to the left of \/ and greedy
to the right of it.  In other words, given

  * ^Subject:(.*:)? *\/[^ :]+\<.*

then this part:

  * ^Subject:(.*:)? *

will consume the least possible amount of stuff that still allows this 
part:
                     \/[^ :]+\<.*

to match.  Thus given

Subject: FW: re: the three little pigs

the first part (to the left of \/) should match 

"Subject: "

and the right-hand part will match

         "FW: re: the three little pigs"

i.e., the 'F' (and 'W') isn't either a space or colon,
      the ':' after "FW" matches \<
      and " re: the three little pigs" matches .*
...
The thing is that it creates a file with the subject name but it has the 
Fwd: and it has spaces.  What I need is the fw or fwd removed and the 
spaces turned into "_".  I am assuming that i would use the "s/\s/_/" but 
not really sure about that nor do i know where to put it.

Here's what I'd try:

:0
* ^From.*gerber
* ^Subject:
{
SUBJ=`formail -zxSubject: | \
        sed -e 's/[Ff][Ww][Dd]*: //' -e 's,/,%,' -e 's/ /_/'`


This will catch FW: and FWD: and Fwd: and fw: etc., but it'll also
catch "fwdd:" and "fwddddddddddd:" and the like.  You might want to
see if replacing '*' with '?' works (may depend on your sed) so you
only catch fw and fwd not fwddddddd....  

regards,
-- 
Neither I nor my employer will accept any liability for any problems
or consequential loss caused by relying on this information.  Sorry.
Collin Park                         Not a statement of my employer.

_______________________________________________
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>