Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions Subject: Re: How do I find a word? Message-ID: <1991May1.074339.27773@athena.mit.edu> Date: 1 May 91 07:43:39 GMT References: <26716@adm.brl.mil> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 20 In article <26716@adm.brl.mil>, RSS%CALSTATE.bitnet@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@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710