On Fri, 13 Jun 1997 09:42:50 -0400,
"Timothy J. Luoma" <luomat(_at_)peak(_dot_)org> wrote:
Your message regarding "The Subject of My Email of Wed Jun 11 1997
00:49:21 -0400 was read on Wed Jun 11 1997 07:32:22 -0700.
what I would like to do it take everything AFTER the 'regarding '
and before the ' was' and put it into the SUBJECT line, so this
message would look like this:
To: "Timothy J. Luoma" <luomat(_at_)peak(_dot_)org>
Subject: Read Receipt -- The Subject of My Email of Wed Jun 11 1997
00:49:21 -0400
(I realize that Subject line is getting a little long)
Here's an attempt which doesn't use external processes:
:0
* ^Subject: Read Receipt$
* ^X-Prefiled: mailer
* B ?? ^^( *$)*Your message regarding \/\
.*$?.*[0-9][0-9]:[0-9][0-9]:[0-9][0-9] [ -+][0-9][0-9][0-9][0-9]
{
# Desired string is now in $MATCH but might contain newlines
...
The * B ?? ^^... means, match from the start of the body of the
message. The regex is wired to allow empty whitespace before the
actual message, including newlines, and optionally one newline within
the match.
If you really really want to have the full date in the reply, you'll
have to run the $MATCH through something like the tr command you had
(perhaps instead turning the newline into newline plus tab instead of
generating a single overlong header line), but frankly, I would think
it's both simpler and more readable to just be content with whatever
the first line of the message happens to catch. The In-Reply-To header
on the generated reply should be enough for most people if the Subject
isn't enough.
(Also, are you sure the receipt doesn't contain a trailing " at the
end of the original subject?)
sed 's/.*regarding\ //g' | \
sed 's/was.*//g' |\
The problem with these is that sed does greedy matching. If the
Subject contains either of the words "regarding" or "was" (including
"swastika" and other substring matches), it will be butchered.
I haven't tested this but the idea should be evident, I hope. If not,
feel free to follow up,
/* era */
--
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r. <http://www.iki.fi/~era/>
* Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>