How do I find a word?

Jonathan I. Kamens jik at athena.mit.edu
Wed May 1 17:43:39 AEST 1991


In article <26716 at adm.brl.mil>, RSS%CALSTATE.bitnet at vm.usc.edu (Richard S. Smith) writes:
|> 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?

  It's difficult to answer this question unless you say what utility you
intend to use the regular expression with.

  For example, with emacs (and possibly with ex and vi, I'm not sure), you can
use "\<" and "\>" to delimit a word in a regular expression.

  With "grep", you can use the "-w" argument to tell it to look for words only.

  With "perl", you can use "\b" to signify a word boundary.

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list