procmail
[Top] [All Lists]

Re: regexp question(s)

1998-07-01 13:16:32
On 1 July 1998, Jim Murphy <murphyja(_at_)cig(_dot_)mot(_dot_)com> wrote:
I'm no expert on regular ecpressions, but I'm trying to come to
grips with what can or can't be done with them in procmail.  I hate
spawing another process, it something can be done internally.  In the
features file it states that procmail "Uses standard egrep regular
expressions".  So using the man pages from several operating systems
as a guide I've tried to write a recipe to find lines like:

      Subject: AB000000055449 etc...
      Subject: XYZ155449 etc...
      Subject: something... XYZ155449 etc...

where "AB" and "XYZ" will always be common no matter what the numeric
portion reads.  The best I've been able to come up with that works is:

      * ^Subject:.*(XYZ[0-9]+|AB[0-9]+)

but this does find lines I didn't want it to catch(ie Subject: AB3
etc...)  The following perl statement does exactly what I want to
do(so far):

      /^Subject:.*(AB|XYZ)[0-9]{5,}/

but so far I haven't been able to get procmail to catch the lines with
this kind of statement.

What I'm looking for is what expressions procmail excepts.  Is
their some document I can go to that will tell me what procmail
can/can't do?  What I read in the egrep man pages would indicate
that "[0-9]{5,}" should work(at least using egrep on the systems I'm
using).  I've check the archives but so far have not been able to find
anything that would tell me what I'm looking for.
[...]

    The {...} is a non-standard extension of regexps (not that you
should actually trust procmail manual and believe that the regexp syntax
used by procmail is actually following any standard...).  You might try
something like

        * ^Subject:.*(XYZ|AB)[0-9][0-9][0-9][0-9][0-9]

instead (not tested).

    Regards,

    Liviu

-- 
Dr. Liviu Daia                   e-mail:   daia(_at_)stoilow(_dot_)imar(_dot_)ro
Institute of Mathematics         web page: http://www.imar.ro/~daia
of the Romanian Academy          PGP key:  finger 
daia(_at_)stoilow(_dot_)imar(_dot_)ro

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