procmail
[Top] [All Lists]

Re: How To Extract.

2005-04-08 23:31:41
multimedia-fan(_at_)myrealbox(_dot_)com:

## Get the domainpart of the email address, no subdomains.

  # domain portion
  :0
  * FROM_DOMAIN ?? \/()\..*\.[a-z][a-z]+$
  { DOMAIN=$MATCH }

I tested \..*\.[a-z][a-z]+$ in Regexp coach and it matched the exact
thing that I was looking for.

   :0
   * FROM_DOMAIN ?? ()\/\.[^.]+\.[a-z]+^^
   * MATCH ?? ^^\/.+
   { DOMAIN=$MATCH }


Didn't you Regexp-coach complain about the '[a-z][a-z]+'? 
;-)


And how about .co.uk / .ac.uk / .com.tw etc.? In DNS-speak they 
are domains, but not in registration practice.

   :0
   * FROM_DOMAIN ?? ()\/\.[^.]+\.((ac|co)\.uk|com\.tw)^^
   * MATCH ?? ^^\/.+
   { DOMAIN = "$MATCH" }
   :0E
   * FROM_DOMAIN ?? ()\/\.[^.]+\.[a-z]+^^
   * MATCH ?? ^^\/.+
   { DOMAIN = "$MATCH" }


The extra condition that matches on MATCH, is to remove the newline.

If you don't want the dot at the start, just move the \/ operator 
in the FROM_DOMAIN condition lines one step to the right, so after 
the initial \.

(all untested)

-- 
Grtz, Ruud

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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