procmail
[Top] [All Lists]

regular expression language in procmail

1997-03-06 14:34:19
I have a procmail 3.11pre4 recipe, that receives mail from a number of
different addresses.  All of these addresses are consistent in that the
address is $list followed by "-on".  This receipe, will simply stuff the
word SUBSCRIBE in the subject line, and re-send it to the $listreq address.

It can figure out the $listreq address by taking the word prior to
-on(_at_)mail-list(_dot_)com and stick on 
-request(_at_)mail-list(_dot_)com(_dot_)  I found the
following idea in the best of procmail archive, and adapted it slightly.


:0
* ^TO \/[a-zA-Z]+-on(_at_)(_dot_)*
* ^TO \/[a-zA-Z]+
{
baselist=$MATCH
}



And when mail sent to chistes-on(_at_)dispatch(_dot_)mail-list(_dot_)com 
arrives, that
regular expression pulled chistes out just like I wanted, and stuck it in
the baselist variable.



procmail: Score:       0       0 "(^(Precedence:.*(junk|bulk|list)|To:
Multiple recipients of |(((Resent-)?(From|Sender)|X-Envelope-From):|>?From
)([^>]*[^((_dot_)%(_at_)a-z0-9])?(Post(ma?(st(e?r)?|n)|office)|(send)?Mail(er)?|daemon|mmdf
|n?uucp|LIST(SERV|proc)|NETSERV|owner|r(e(quest|sponse)|oot)|b(ounce|bs\.smtp)|e
cho|mirror|s(erv(ices?|er)|mtp)|A(dmin(istrator)?|MMGR|utoanswer))(([^).!:a-z0-9
][-_a-z0-9]*)?[%@>       ][^<)]*(\(.*\).*)?)?$([^>]|$)))"
procmail: Score:       1       1 ""
procmail: Assigning "MATCH="
procmail: Matched "chistes-on(_at_)dispatch(_dot_)mail-list(_dot_)com"
procmail: Match on
"(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To):(.*[
^a-zA-Z])?) \/[a-zA-Z]+-on(_at_)(_dot_)*"
procmail: Matched "chistes"
procmail: Match on
"(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To):(.*[
^a-zA-Z])?) \/[a-zA-Z]+"
procmail: Assigning "baselist=chistes"



However, when I sent a message to 
domain-name-on(_at_)dispatch(_dot_)mail-list(_dot_)com, no
match !!

The dash in domain-name seems to be causing the regular expression to go
awry (that's the egocentric way of looking at things :-)


procmail: Score:       0       0 "(^(Precedence:.*(junk|bulk|list)|To:
Multiple recipients of |(((Resent-)?(From|Sender)|X-Envelope-From):|>?From
)([^>]*[^((_dot_)%(_at_)a-z0-9])?(Post(ma?(st(e?r)?|n)|office)|(send)?Mail(er)?|daemon|mmdf
|n?uucp|LIST(SERV|proc)|NETSERV|owner|r(e(quest|sponse)|oot)|b(ounce|bs\.smtp)|e
cho|mirror|s(erv(ices?|er)|mtp)|A(dmin(istrator)?|MMGR|utoanswer))(([^).!:a-z0-9
][-_a-z0-9]*)?[%@>       ][^<)]*(\(.*\).*)?)?$([^>]|$)))"
procmail: Score:       1       1 ""
procmail: No match on
"(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To):(.*[
^a-zA-Z])?) \/[a-zA-Z]+-on(_at_)(_dot_)*"



So my question is, what other parsing solutions are at my disposal ?

The man page lead me to believe that egrep (1) was used as the regular
expression parser, along with some extensions.  I tried parsing for \w,
which I figure is a valid egrep expression for word, and procmail does not
recognize it.

Can I do regular expression stuff in the action, and not just the conditions ?

How would I chop things off from the end, as in substring ?  That is, if I
could work from the back of the email address, I could remove the constants
going back to the on(_at_)(_dot_)

Thanks for any hints.

mark



mark david mcCreary
Internet Tools, Inc.            4615 Post Oak Place, Suite 140
mdm(_at_)internet-tools(_dot_)com          Houston, Texas 77027
http://www.internet-tools.com   713.627.9600


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