procmail
[Top] [All Lists]

Re: $MATCHing on the left

1999-09-04 00:28:03
On Fri, 3 Sep 1999 15:14:22 -0700 (PDT), Vince LaMonica
<vjl(_at_)cullasaja(_dot_)com> wrote:
* ^Subject: Same Text Here Always.*\/[fwsyxzm0-9]+
The problem is that I originally wanted the part that I'm $MATCHing
to be the first part of the subject. Eg: w2000 Same Text Here
Always. I only want to match the 5 character string to use as the
name of the gzip file and the lockfile. I was unable to stop the
$MATCH though [it would match the entire subject].

Your regular expression says "one or more of the listed characters,
for as long as possible". The way to say "five of the listed
characters" would be something like

    * ^Subject: Same Text Here Always.*\/\
       [fwsyxzm0-9][fwsyxzm0-9][fwsyxzm0-9][fwsyxzm0-9][fwsyxzm0-9]

Some regular expression engines will let you say (regex)\{5\} but
Procmail doesn't have that facility. There's also (regex)\{1,5\} which
means "at least one but no more than five" and which is useful when
you can't be sure there will always be five characters there (the
above condition will fail altogether if they aren't there); in
Procmail, that would have to be phrased something like this:

    * ^Subject: Same Text Here Always.*\/\
       [fwsyxzm0-9][fwsyxzm0-9]?[fwsyxzm0-9]?[fwsyxzm0-9]?[fwsyxzm0-9]?

Am I allowed to speculate that the class [fwsyxzm0-9] is a lazy
shorthand for a limited set of possible (five-character?) strings?
Perhaps it would be better to just list those strings as alternatives
then. ...\/(string1|string2|string3)

using v3.10pre4

Like Stan said already, time to upgrade. I don't even see a 3.10pre4
in the HISTORY file but I guess that would have to be from autumn
1994. If you mean 3.11pre4, which was in widespread use for a long
time, it is now almost four years old and surpassed by 3.12 and 3.13
which introduced some rather important bug fixes. The newest version
is 3.13.1; you can get it from <http://www.procmail.org/>

Hope this helps,

/* era */

-- 
 Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
  Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition

<Prev in Thread] Current Thread [Next in Thread>