procmail
[Top] [All Lists]

Re: Generic mailing list detection?

2002-07-18 10:50:50
Bart suggested to Brad,

| I think this would work:
| 
| # Grab everything up through the @ (in case of hyphens after the @)
| :0
| * MAILING_LIST_NAME ?? ^^\/.+-(owner|admin)@
| { list_left_side=$MATCH }
| 
| # Grab everything up through the last hyphen
| :0
| * list_left_side ?? ^^\/.+-
| { list_name_part=$MATCH }

OK so far.

| # Grab everything except that last hyphen
| :0
| * list_name_part ?? ^^\/([^-]|-[^-])+

Hmm.  I misread that at first, but it's equivalent to this:

  * list_name_part ?? ^^\/(-?[^-]+)+
  
and it will break on names with two or more consecutive medial hyphens.  We
can fix that this way:

  * list_name_part ?? ^^\/(-*[^-]+)+
  
but I prefer this approach:

  * list_name_part ?? ^^\/.*[^-]
 
to grab everything up through the last character that isn't a hyphen.
Then, as Bart posted,

| { list_name=$MATCH }

More recent versions of procmail allow rematching within a recipe, letting us
condense it all to this:

 :0
 * MAILING_LIST_NAME ?? ^^\/.+-(owner|admin)@
 * MATCH ?? ^^\/.+-
 * MATCH ?? ^^\/.*[^-]
 { list_name=$MATCH }

Thanks to Dallman for the acknowledgment.

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