Ok fair enough. I've noticed that having the \ doesn't hurt for a dash.
Now what about matching a question mark and an equals sign?

If you read perlre closely you will find it says that it never hurts to put a backslash before a special character that you want to match as a character. So this is a case of "does nothing, but doesn't hurt".


I've read perlre and perlretut and understand regular expressions, but
there is no clear cut way of matching these characters, either outlined
by this document or any Spamassassin document I've come across so far.

For the most part you can match any character by the appearance of the character. Any character with special meaning needs to be escaped in some way. The easiest way is usually with a backslash, but in some cases you can also do it by making it a member of a character class.

So for you questionmark case, you could do \? or [?], as most of the special characters lose their meaning in a character class. The exceptions are obviously right bracket, backslash, and dash becomes special if it isn't the first character.

/\=\?koi8\-r\?/

This should work. You don't need to escape the dash, and I'm pretty sure you don't need to escape the equal sign; just the questionmark.

Also, you may want to handle this in both uppercase and lowercase, so you could do

   /=\?koi8-r\?/i

And you probably don't need the = sign to get reasonably reliable matching.

       Loren


Reply via email to