Confessions of a regexp idiot.
I asked for some help, but just to show I am willing to
try and understand regexp, here are my synapse busting
attempt to understand regexp:
******************************************
Warmup excercise.
Here is a matching recipe for the text X-Mailto-Comment:
Already I have word and string confused, X-Mailto-Comment:
is a string right?
:0
* ^X-Mailto-Comment:[ ]+\/.*
{ ORIG=$MATCH }
* Begin a condition
^ start at beginning of line
X-Mailto-Comment: the text to search for (including ":" ??)
[character list] any single character in character list
(why are these all blanks - why 7??)
+ match at least one occurance
\/ Begin extraction; if there is a match after the
extraction
operator \/, put it into a variable named MATCH
. match any character
* zero or more of preceding item
(hey - what happened to "*" as
"Begin a condition" ?
so for an email header that has X-Mailto-Comment: bozo(_at_)bozo(_dot_)com
this recipe sees "X-Mailto-Comment:" and puts everything after it
into ORIG, which would be " bozo(_at_)bozo(_dot_)com", including the space?
The nuances of this all just confound me.
==================================================
Here is what I have working that reads an originators email address
out of the body of the email - it also writes the date and subject
to a log file:
:0
* ^Subject:.*Re: WebSite
{
:0B
* Sendersemail:[ ]*\/[^ ].*
{ ORIGMAIL = $MATCH }
:0cwi:
* ^Subject:[ ]+\/.*
| echo "`date` $ORIGMAIL -" $MATCH >>$HOME/mail_log
:0c
| formail -cz \
| $SENDMAIL -oi $ORIGMAIL
}
What does [^ ].* mean as opposed to .* ??
Remember, I am trying to avoid using the body to keep the
originators email address - I am going to try to append it
to the subject line and retrieve it from there. To mark
where the email address starts in the subject line I am
going to add two characters - "*-" would be nice, but
then i figure they are special characters and might be
hard to match - would you do \*\- to match them?
Again, confusion reigns. Lets call them "99" for now.
:0
* ^Subject:.*Re: WebSite
{
:0
#capture who is sending
* ^From:.[ ]*\/.*
{ REALSENDER = $MATCH }
# now strip out email address from subject line
* ^Subject:.[99]*\/.*
{ ORIGINATOR = $MATCH }
:0cwi:
* ^Subject:[ ]+\/.*
| echo "`date` $ORIGINATOR -" $MATCH >>$HOME/mail_log
:0c
| formail -cz -I "From: $REALSENDER" \
-I "To: $ORIGINATOR" \
| $SENDMAIL -oi $ORIGINATOR
}
==========
Do you think this will work, or have I committed agregious procmail
sins?
Thank you for your help
Tom
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail