procmail
[Top] [All Lists]

Re: How can I put more than one word in the VARIABLE ?

2002-05-24 09:18:34
S Semple is getting introduced to procmail's special '$' condition:

<< [...] I looked at your code and it works great but the double $ $ confused 
me. Im not much of a shell script person, but I dont think I have ever seen the 
$ $ before [...] >>

The '$' here is a special procmail condition and not a shell construct.
Basically, when found at the beginning of a condition, it tells procmail
the rest of the condition contains variables that need to be evaluated. 
Without it there's no way for procmail to know whether the $ token is
the regular expression for end of line or the start of a variable name.
 
<< On the :0 B: 
* .*
 
I guess what you are saying is not to use .* when searching the body. [...] >>

No, it has nothing to do with body vs. header searches. It's plain
vanilla regular expression logic.  ".*" says zero or more of anything.
So logically, if anything at all may or may not precede what you're
trying to match, it's not necessary to include it. There are reasons to
use ".*" at the beginning or end of a regular expression, but not in
your example.  Probably most times you see it at the beginning or end
of a regular expression, it's superfluous.

<< Would it be accptable to use the following 
:0 B:
 * Sex.*Girls
 
Which would catch the text sex and girls anywhere in the body. >>

Yes, that's a correct use of ".*". However, that regular expression
will match any of:

  Sex with Girls
  Sexy Girls
  SexGirls
  The sailor demonstrated the sextant for the visiting boys and girls.
   
Further, it will not match (split over 2 lines):

Have fun watching the Sexy
Girls while they ...

The tokens "\>" amd "\<" force matches on word boundaries only, with
the added bonus of matching a newline also.  The "." in ".*" does not
match newline.  So, for example, to rewrite your regular expression to
work more as expected, you might use a condition something like:

  * \<sexy?\>.*\<girls\>     # the y? make "y" optional

I can hardly wait to see how many bounces this this message is going to
generate. :-(  All of this is more about reqular expressions, than
about procmail. You will probably want to become at least minimally
proficient with regular expressions to use procmail.

Lastly, and intended constructively, it would be helpful if you could
figure out how to set your mail software to wrap lines (oh boy, here we
go again) at something like 70 to 72 characters.  It's much easier for
respondents to quote and is, therfore, more useful in the list archives.
Frankly, when quoting seems like it's going to be like forcing a square
peg in a round hole, I often decide it's not worth the time answering
the message.

-- 
Reply to list please, or append "6" to "procmail" in address if you must.
Spammers' unrelenting address harvesting forces me to this...reluctantly.


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail