Re: regular expression to kill Lines:

From: Kevin Martin (cannon@nic.com)
Date: Mon, 3 Feb 1997 07:59:41 -0500 (EST)

On Mon, 3 Feb 1997, Hardy Griech wrote:

> > /^Lines: [5-9][0-9][0-9]/h:j
> > /^Lines: [1-9][0-9][0-9][0-9]*/h:j
>
> Hmm, what are those /^ and /h patterns?

I'm using an older format which allows you to look at any line
in the header, which is what the /h: is about. The action
following the /h: is j for junk, but could be any valid
action. With /h: you can even look for non-standard X- lines
or comments.

The leading ^ means "anchor this comparison at the beginning
of the line". Gives the test just a bit more information to
work with; if it doesn't get a match on the first character
of the line, it doesn't have to look any further.

The ability to anchor a regular expression is important --
let's say you wanted to read a binaries group and kill
anything LESS than 50 lines long. To do that, you have
to be able to lock down the right-hand end of the line:

/^Lines: [1-9]$/h:j
/^Lines: [1-4][0-9]$/h:j

The trailing, unescaped $ means "end of line". "Lines: 8" would
match this test and trigger the specified action; "Lines: 80" would
not.

But if you omitted the $, then "Lines: 80" _WOULD_ still trigger
the action.

-- 
Kevin <cannon@nic.com>