procmail
[Top] [All Lists]

RE: regex code to strip something of an address

2008-02-29 14:14:59
Stefan S. wrote Tuesday, February 26, 2008 8:06 PM:

What can I do if I don´t want to strip everthing after the
@-sign, but for example ".COM" from TEST(_at_)EXAMPLE(_dot_)COM (would
then be TEST(_at_)EXAMPLE).

  :0
  * ^TO\/(_dot_)*(_at_)EXAMPLE\(_dot_)COM\>
  * MATCH ?? ^^\/(_dot_)+(_at_)[^(_dot_)]+
  { FROMADDR = $MATCH }

* ^TO\/(_dot_)*(_at_)EXAMPLE\(_dot_)COM\>?

Oh, and your syntax is not correct there.  You can't
just stick a regex '?' on the end of a compound character-macro.
And even if it did work, it would negate what you are trying to do,
namely anchor the "com".  That is, this (which is correct
syntax but still wrong logic):

     * whatever(\>)?

would still match on "whateveritis" as well as "whatever".
That's because procmail doesn't want to do any more work than
it must.  It finds that the text regex string "whatever" matches
"whateveritis" just fine, so it doesn't bother trying to see
if something else that you say can be there one or zero times
is actually there. Zero times suffices.  Well, it does bother
looking, but finds a match at zero times.

In any case, just 

  * ^TO\/(_dot_)*(_at_)EXAMPLE\(_dot_)COM\>

will also match if the ".com" is anchored to the end of the line.

Dallman


____________________________________________________________
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>