procmail
[Top] [All Lists]

Re: escaping special characters (in general)

1995-10-30 21:17:44
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).
 
Well, there are two possibilities I can think of.  One is to set
a temporary variable in your procmailrc and then escape it in the way
Soren suggested:

string=text(containing r.e.chars)

:0
* $ ^Subject:.*$\string
foo


The other way is to make a simple text filter with sed:

sed 's/\([][)(.*$^+?]\)/\\\1/g'
          ^^^^^^^^^^
          These are the regular expression characters.  Note that ]
          must be listed first.  I may have missed some.

Then anything you need to escape you simply pipe through this filter.

-- 
Tim Pickett                                     
tlm(_at_)yoyo(_dot_)cc(_dot_)monash(_dot_)edu(_dot_)au
"I've shrunk!"                                 
tbp(_at_)molly(_dot_)cs(_dot_)monash(_dot_)edu(_dot_)au