procmail
[Top] [All Lists]

Re: catching domain or domain and hostname

1998-03-20 05:57:06
On Thu, 19 Mar 1998 22:01:06 -0800 (PST), David Hunt <dh(_at_)west(_dot_)net>
wrote:
On Thu, 19 Mar 1998, Timothy J Luoma wrote:
Is this a proper regex to catch both any hostname and without any
hostname? 
* ^From:.*@(.*\.)?work\.com
How about foo(_at_)free(_dot_)work(_dot_)comp(_dot_)net ?  I think I'd 
restrict the expression to
non-whitespace between @ and \. , and add \> to the end, to be more certain.
     * ^From:.*@([^   ]+\.)?work\.com\>

I'd be even more restrictive. At the very least, I'd exclude
additional @:s and commas, but since you know what's valid in a host
name, why allow anything else?

    * ^From:.+@([a-z0-9][-a-z0-9_]*\.)*work\.com\>

Caveat: This is not checked against any RFC. (Somebody even told me
leading numbers are disallowed but I've seen hosts which have them.
The spamhaus 1stfamily.com comes to mind.)

You could still accidentally match on e.g. work.com.au but tightening
up the \> to something better is left as an exercise ...

Hope this helps,

/* era */

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>

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