On 02/13/2017 01:01 PM, Barco van Rhijn wrote: > Thanks for pointing out the fact that a pipe means or. I'm still quite > new to regex but I'm learning quickly.
The '|' symbol has many names and meanings <https://en.wikipedia.org/wiki/Vertical_bar>. It is only a pipe in the context of interprocess communication. It is not appropriate to refer to it as 'pipe' in other contexts. > I've reviewed the page you reference on custom handlers. > > I've looked into the custom handler file and notice 'discard_pattern' > after comment suggesting regex here >> > > # the message if more than one matches, the precedence is DISCARD over > # REJECT over HOLD. > DISCARD = re.compile(r'discard_pattern', re.IGNORECASE) > REJECT = re.compile(r'reject_pattern', re.IGNORECASE) > HOLD = re.compile(r'hold_pattern', re.IGNORECASE) > # And if the following regexp matches the Subject: header, the message will > # be unconditionally accepted. > ACCEPT = re.compile(r'accept_pattern', re.IGNORECASE) > 1. Am I right in assuming that I can replace the text discard_pattern' > with python formatted regex? > 2. Can I have multiple Discard, Hold, > Reject or Accept lines? You really need to have an understanding of Python in order to turn that example into a useful handler for your purpose. If I understand correctly, you want to create regexp matches to be applied to the message text and discard the message if the regexp matches. To do that, you could replace lines 38 through 49 of that example with something like D1 = re.compile(r'\bbadword\b', re.IGNORECASE) D2 = re.compile(r'\ba\s+bad\s+phrase\b', re.IGNORECASE) and more D3, D4, etc. if you like Then delete lines 52 through 59 and replace lines 64 through the end with for cre in ( D1, D2, and as many more Dn as you've defined ): if cre.search(payload): Moderate.do_discard(mlist, msg) Note that indentation in Python is significant. The above lines are indented 12 spaces, 16 spaces and 20 spaces for the first, second through sixth and seventh respectively. That said, you really need to be comfortable with the tutorial at <https://docs.python.org/2/tutorial/index.html> before you try to do this. -- Mark Sapiro <[email protected]> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan ------------------------------------------------------ Mailman-Users mailing list [email protected] https://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: https://mail.python.org/mailman/options/mailman-users/archive%40jab.org
