procmail
[Top] [All Lists]

scanning the topmost N lines

1997-05-09 14:31:00
A while back -- at least a year if not longer -- somebody asked how to see
if a regexp is matched in the first six lines of the body.  I suggested the
following, where "(^.*)?" appears 6 - 1 = 5 times:

  :0B
  * $ ^^.*(^.*)?(^.*)?(^.*)?(^.*)?(^.*)?$pattern
  action

But David Little's question this week involved checking the topmost thirty
lines, and thirty are a lot more than six.  Yes, one could add "(^.*)?" to
the regexp another twenty-four times, but that would be a real pain to type
in at first and to change later if the number of lines to search changed.

For thirty lines methods such as those already posted (including the ones I
posted Wednesday) seem more practicable, but something like the above can do
the job very well when there are only a few lines in the area that counts.

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