Robert Brown wrote again:
[I had suggested this:]
| > :0:
| > * $ ^TO$\foo(_at_)bar\(_dot_)com\>
| > foo
| OK, but this doesn't address my original question: is there a program or
| script which, taken a given regular expression, will output a string with
| all the regular expression/special characters escaped? I mean, my procmail
| filter is being "built up" by my own sendmail, so that Subject:'s that I send
| are given "Priority: A" so it is at the top of my list in mush (Mail User's
| SHell).
You don't need a separate program if you're going to use that escaped version
in a procmailrc. Procmail's $\ facility will do it for you.
It would be easy enough to work something up with sed, but here are the rubs:
different programs that use regexps have different ideas of which characters
are magic; plus there are some characters that become magic when escaped, and
you want to make sure not to touch those.
| So, I'm doing "formail -x Subject" and putting:
|
| :0f
| *^Subject: (re:)? *the subject
| | formail -I "Priority: A"
|
| But, if "the subject" contains any regular expression chars (e.g., "*", "(",
| "?", etc.), then I'm screwed.
Right. That's exactly what we're answering here.
THE_SUBJECT="string including some characters that are magic in regexps"
:0hf
* $ ^Subject: (re: *)? *$\THE_SUBJECT
| formail -I "Priority: A"
| Do you see my problem?
I guess not, because this is the second time you've stated it, and both times
it looks like exactly what we're answering. Maybe I see the problem but you
don't understand the answer. Copy it carefully and give it a try, please,
with a logfile and verbose logging so that we can find out what happened if
it doesn't work. Remember that "$\" requires at least procmail 3.11pre0.
Moreover, I don't follow why you have to extract the subject with formail -x
or even with the MATCH operator. Perhaps if you explained more of what
you're trying to do it would make more sense to us.