procmail
[Top] [All Lists]

Re: how can I eat the Re:

1997-04-17 15:51:00
Robert Nicholson wrote,

| > > I'm trying to capture all the subject without the Re:'s
| > > 
| > > :0
| > > * ^Subject: *(Re: )*\/[^ ].*
| > > { SUBJECT=$MATCH }
| > > 
| > > This doesn't work.

David Hunt suggested,

| > Try this. It's ugly, but it works.
| > 
| >     * ^Subject: +(Re: )*\/(([^R].*|.[^e].*|..[^:].*)|..?$)

And Robert asked,

| Why didn't my attempt work? I really like to keep these things as simple
| as possible.

Remember that, as long as the entire condition matches and MATCH will be
assigned at all, procmail inserts the extraction operator as far to the left
as it can.  So in

  * ^Subject: *(Re: )*\/[^ ].*

"(Re: )*" is matched to the null string between "Subject:[space(s) if any]"
and "Re:", and "Re: whatever the rest is" matches "[^ ].*".

David's more complicated expression allows a match only if the text to the
right of the extraction operator (1) doesn't start with R, (2) doesn't have
e as its second character, (3) doesn't have a colon as its third character,
or (4) is exactly one or two characters long.  It will fail if the subject
text is right up against the colon without a space in between, but that is
very rare.  (More often one finds no space after "Re:".)

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