How do I find a word?

Richard S. Smith RSS%CALSTATE.bitnet at vm.usc.edu
Wed May 1 07:41:24 AEST 1991


I get the feeling there's no good answer to this question, but I
am asking it anyway...

Is there a SIMPLE, NON-PAINFUL way to set up a regular expression so
that it will match a given string only when it occurs as a word, i.e.,
delimited by non-alphanumeric characters or by line boundaries?

In other words, I am looking for a simple, generalized way to find
"foo" when it occurs as "foo bar" or "foo-bar" or "foo: bar" but NOT
as "foobar".  I am hoping there is a simpler answer than:

"[^A-Za-z0-9]foo[^A-Za-z0-9]"

Thanks to anyone who can help.

Richard Smith - RSS at CALSTATE.BITNET



More information about the Comp.unix.questions mailing list