[Mailman-Users] OT - Regex help (was: Re: About Spam Filtering

Tanstaafl tanstaafl at libertytrek.org
Fri Feb 15 15:41:14 CET 2013


Apologies for the OT post, but I've been struggling with a regex for a 
long time, trying to get it to work with my postfixadmin vacation.pl, 
and for the life of me, I can't seem to get it right. I've asked 
numerous times on the postfixadmin list, but no one there has been able 
to help.

If this is too OT or no one can help, that is ok, but I just thought 
maybe someone here might be able to see why this line isn't working...

Here is the line with the regex in it:

> elsif (/^from:.*+(bounce|do-not-reply|facebook|linkedin|list-|myspace|twitter)/i) { $logger->debug("Multi-string From header matching $1: $2 found; exiting"); exit (0); }

What I want is for it to match any 'From' header that contains any one 
of the strings in it (ie, bounce, do-not-reply, etc). We get a lot of 
list related stuff that the vacation.pl responds to that I don't want it 
to respond to, so I want a one-liner that I can manually add these 
strings too whenever I see one go out that shouldn't, so we don't 
respond to things that shouldn't be responded to.

Does anything jump out at you as to why it isn't catching anything?

Thanks in advance (to Mark or anyone who might be able to help)...

On 2013-02-12 1:37 AM, Mark Sapiro <mark at msapiro.net> wrote:> METU 
E-List Admin wrote:
 >> --------------------------------------------
 >> $ bin/config_list -o - REGISTER | grep -A20 header_filter_rules
 >> header_filter_rules = [('^X-Mailer: (?!Microsoft Outlook .*)$', 7,
 > This regexp won't work. The negative lookahead does not advance the
 > current position so your regexp says look for 'X-Mailer: ' at the
 > beginning of the line not followed by 'Microsoft Outlook .*' but
 > followed immediately by the end of the line, so it will only match a
 > header like 'X-Mailer: ' not followed by anything.
 > What you want is
 > ^X-Mailer: (?!Microsoft Outlook .*).*$
 > or just
 > ^X-Mailer: (?!Microsoft Outlook .*)
 > or maybe even just
 > ^X-Mailer: (?!Microsoft Outlook )

More information about the Mailman-Users mailing list