[MlMt] exclude emails in address pattern ?

David Shepherdson david at shepherdson.name
Thu Nov 1 07:16:23 EDT 2018


On 27 Oct 2018, at 18.35, Max Rydahl Andersen wrote:

>>>
>>>> Is there a way via the address pattern to state .*@example\.com is 
>>>> good, except dad at example.com and wife at example.com ?
>>>
>>> If you can describe it with a regular expression, then you can put 
>>> it in. For example, you might be able to do something along the 
>>> lines of:
>>>
>>>     .*(?<!dad|wife)@example\.com
>>
>> For people not used to regular expressions, this uses so-called 
>> negative lookbehind (if you want to google it). It is also possible 
>> to use negative lookahead:
>>
>> 	(?!(dad|wife)@).*@example\.com
>>
>> That is (perhaps) a bit easier to read in this case. (I have not 
>> tested it.)
>
> mailmate uses PCRE-like syntax for its regular expression, right ? 
> then regextester.com is a nice tool for testing.
>
> Then yours seems faulty: https://www.regextester.com/?fam=105641 
> (still matches dad and wife).
>
> but Davids (https://www.regextester.com/?fam=105642) seems more 
> precise (and actually seem to work for me in mailmate)

Benny’s should actually be more precise — mine is vulnerable to 
matching things that you might not want to exclude (e.g. it wouldn’t 
just match dad at example.com, but also grandad at example.com or 
trinidad at example.com).

But I would have thought Benny’s needs anchoring at the start of the 
address in order to work as desired; maybe this is a difference with the 
specific regular expression engine used in MailMate, but if you do 
something like:

     ^(?!(dad|wife)@).*@example\.com

…then I would expect it to work (and only filter out the specific 
addresses listed in the bracketed part at the beginning).


> In any case thanks for both answers - it worked ;)

That’s the main thing — happy to help! :-)

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freron.com/pipermail/mailmate/attachments/20181101/6175c956/attachment.html>


More information about the mailmate mailing list