procmail
[Top] [All Lists]

Re: How to Filter Whole Word?

1996-08-22 08:11:09
Larry Renslow asked,

R> I tried this, which I gleaned from the grep man page:

R> :0BHw:
R> * \<ward\>
R> ward

R> It didn't work.

Philip Guenther suggested,

G> :0BHw:
G> * ()\<ward\>
G> ward

G> or

G> :0BHw:
G> * (\<)ward\>
G> ward

Personally I prefer Philip's first suggestion to any other answer I know of,
but just for the record here are some more.  The main thing is to get
something else in front of the backslash so that it can change the less-than
sign into a character-not-in-a-word marker instead of simply making sure the
less-than sign is read.

   :0BHw:
   * \\<ward\>
   ward

That works, but since we expect "\\" to mean a literal backslash, it is
highly, highly counter-intuitive.  I guess that if your search expression
begins with a literal backslash, you need to write "\\\"?

The only strong point it has is that it adds only one more character instead
of two.

   :0BHw:
   * (\<ward\>)
   ward

I like that less than Philip's first example but more than his second one.

Finally,

   :0BHw: # or   .?\<ward\> 
   * .*\<ward\>
   ward

That's what I used to do before Stephen recommended the empty parentheses
to someone on this list.  It was easy to read and understand but probably
runs less efficiently.

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