procmail
[Top] [All Lists]

Re: Matching two or more spaces

1996-01-31 09:02:33
Jim Osborn <jimo(_at_)eskimo(_dot_)com> writes:
I'm obviously overlooking something simple, but I seem to be stuck.
In the following recipe, I'm trying to allow a variable amount of
whitespace between the word "digest" and the number.  However,
if exactly one space is given, it matches as expected, whereas if
two spaces are given, we get an empty MATCH.  What am I doing wrong?
Within the square brackets in the regexp are a space and a tab, but
the result is the same with "digest( )+\/.*", with or without the ().

---------succeeds with one space------------
      GETTING=$MATCH
Assigning GETTING=digest 98

      :0
      * GETTING ?? digest[    ]+\/.*
Assigning MATCH=
Matched "98"

----------fails with two spaces----------------
      GETTING=$MATCH
Assigning GETTING=digest  98

      :0
      * GETTING ?? digest[    ]+\/.*
Assigning MATCH=
Matched ""

For speed reasons, procmail does minimal matching on the left hand side
of the \/.  This forces you to use a regexp like:

* GETTING ?? digest[    ]+\/[^  ].*

Each bracket contains both a space and a tab.  The second forces the
match to start on the first non-whitespace, thus forcing the previous
'+' operator to eat all the whitespace instead of just one.


Philip Guenther

----------------------------------------------------------------
Philip Guenther                 UNIX Systems and Network Administrator
Internet: guenther(_at_)gac(_dot_)edu   Phonenet: (507) 933-7596
Gustavus Adolphus College       St. Peter, MN 56082-1498

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