[comp.editors] DELIMITED search

afsipmh@cidsv01.cid.aes.doe.CA (10/29/90)

 How, in general, can I do delimited searches in UNIX. i.e. How do I
 search for say the string "the" without finding there their other
 thesaurus...... AND including "the" at the beginning and end of a line
 eh?

-- 
Pat Hertel                 Canadian Meteorological Centre
Analyst/Programmer         2121 N. Service Rd.        % rm God
phertel@cmc.aes.doe.ca     Dorval,Quebec              rm: God non-existent
Environment Canada         CANADA           H9P1J3

steinbac@hpl-opus.HP.COM (Gunter Steinbach) (10/30/90)

In comp.editors, afsipmh@cidsv01.cid.aes.doe.CA writes:

>    How, in general, can I do delimited searches in UNIX. i.e. How do I
>    search for say the string "the" without finding there their other
>    thesaurus...... AND including "the" at the beginning and end of a line
>    eh?

I'm not quite sure what you mean with "in UNIX", but within vi at least,
you can search for

/\<the\>

and you will find only stand-alone the's.  Also \<the finds words
beginning with the, etc.

	 Guenter Steinbach		gunter_steinbach@hplabs.hp.com

GHAVERLA@vm.ucs.UAlberta.CA (G Haverland) (10/31/90)

In article <1990Oct29.134654.18929@cid.aes.doe.CA>, afsipmh@cidsv01.cid.aes.doe.CA writes:
 
>
> How, in general, can I do delimited searches in UNIX. i.e. How do I
> search for say the string "the" without finding there their other
> thesaurus...... AND including "the" at the beginning and end of a line
> eh?
>
>--
>Pat Hertel                 Canadian Meteorological Centre
>Analyst/Programmer         2121 N. Service Rd.        % rm God
>phertel@cmc.aes.doe.ca     Dorval,Quebec              rm: God non-existent
>Environment Canada         CANADA           H9P1J3
 
Not sure what UNIX programs you are using, and exactly what your
needs are, but the following will work.  Search for three different
strings, and then combine the results.  The first string to look for
is " the " (the in spaces), the next to look for is "%the" (sorry
caret (begining of line character) doesn't exist on this VM machine),
and the last to look for is "the$" (look for the at end of line).
grep can be told to ignore case (-i) if this is what you are using.
If vi or emacs, there should be a magic variable that can be set
before doing the search.
 
Gordon Haverland, U of Alberta SLOWPOKE Facility

Dan_Bloch@TRANSARC.COM (11/01/90)

afsipmh@cidsv01.cid.aes.doe.CA (Pat Hertel) writes:

> How, in general, can I do delimited searches in UNIX. i.e. How do I
> search for say the string "the" without finding there their other
> thesaurus......

From the shell, you can grep -w the.

In vi or ex, you can search for \<the>\.  These don't have to be used
together- "\<the" would match thesaurus, "the\>" would match lathe.

Now, the fun part.  A really neat mapping to put in your .exrc is

    map  ^R /\<
    map! ^R \>^M

Since one of the mappings in in normal mode and the other is in insert
mode, you can map both sequences to the same key.  To search for the,
you type ^Rthe^R.  Easy on the fingers and on the memory.

Dan Bloch
dan@transarc.com

louk@tslwat.UUCP (Lou Kates) (11/22/90)

In article <1092@vm.ucs.UAlberta.CA# GHAVERLA@vm.ucs.UAlberta.CA writes:
#In article <1990Oct29.134654.18929@cid.aes.doe.CA>, afsipmh@cidsv01.cid.aes.doe.CA writes:
# 
#> How, in general, can I do delimited searches in UNIX. i.e. How do I
#> search for say the string "the" without finding there their other
#> thesaurus...... AND including "the" at the beginning and end of a line
#> eh?
# 
#needs are, but the following will work.  Search for three different
#strings, and then combine the results.  The first string to look for
#is " the " (the in spaces), the next to look for is "%the" (sorry

In vi you can search for \<the\>.

Lou Kates, Teleride Sage Ltd., louk%tswat@watmath.waterloo.edu

spcecdt@deeptht.santa-cruz.ca.us (John DuBois) (12/02/90)

In article <1990Oct29.134654.18929@cid.aes.doe.CA>, afsipmh@cidsv01.cid.aes.doe.CA writes:
 
> How, in general, can I do delimited searches in UNIX. i.e. How do I
> search for say the string "the" without finding there their other
> thesaurus...... AND including "the" at the beginning and end of a line
> eh?

     I just began getting comp.editors so I don't know if this has been
noted yet, but in egrep (and other text processing utilities that
understand egrep-style expressions) you can search for
(^| )the( |$)
You can replace the spaces with [ <tab>] (space followed by tab in
brackets) if you want to include it as a delimiter.

	John DuBois
	spcecdt@deeptht.santa-cruz.ca.us

tmb@bambleweenie57.ai.mit.edu (Thomas M. Breuel) (12/03/90)

In article <107@deeptht.UUCP> spcecdt@deeptht.santa-cruz.ca.us (John DuBois) writes:
   In article <1990Oct29.134654.18929@cid.aes.doe.CA>, afsipmh@cidsv01.cid.aes.doe.CA writes:

   > How, in general, can I do delimited searches in UNIX. i.e. How do I
   > search for say the string "the" without finding there their other
   > thesaurus...... AND including "the" at the beginning and end of a line
   > eh?

Use the RE /\<the\>/. This _is_ documented...

	I just began getting comp.editors so I don't know if this has been
   noted yet, but in egrep (and other text processing utilities that
   understand egrep-style expressions) you can search for
   (^| )the( |$)

But not in VI.

   You can replace the spaces with [ <tab>] (space followed by tab in
   brackets) if you want to include it as a delimiter.

dberg@informix.com (David I. Berg) (12/04/90)

In article <107@deeptht.UUCP> spcecdt@deeptht.santa-cruz.ca.us (John DuBois) writes:
>In article <1990Oct29.134654.18929@cid.aes.doe.CA>, afsipmh@cidsv01.cid.aes.doe.CA writes:
> 
>> How, in general, can I do delimited searches in UNIX. i.e. How do I
>> search for say the string "the" without finding there their other
>> thesaurus...... AND including "the" at the beginning and end of a line
>> eh?
>
The delimiters \< and \> will delimit the first and last characters of
a logical word. This syntax can be used in vi or any of the greps.
To find "the" without also finding all the words in which "the" is
contained as a string, find \<the\>.
  ____
  /   ) __      . ___/                 David Berg (dberg@cougar.informix.com)
_/___/ (_(_ (/ / (__(_                 Informix Software, Inc.
                                       5299 DTC Boulevard, Suite 740
                                       Englewood, CO 80111     (303) 850-0210

The opinions expressed herein do not necessarily reflect those of my employer.

asylvain@felix.UUCP (Alvin "the Chipmunk" Sylvain) (12/12/90)

In article <1990Dec3.171557.16350@informix.com> dberg@informix.com (David I. Berg) writes:
> In article <107@deeptht.UUCP> spcecdt@deeptht.santa-cruz.ca.us (John DuBois) writes:
> >In article <1990Oct29.134654.18929@cid.aes.doe.CA>, afsipmh@cidsv01.cid.aes.doe.CA writes:
> > 
> >> How, in general, can I do delimited searches in UNIX. i.e. How do I
> >> search for say the string "the" without finding there their other
> >> thesaurus...... AND including "the" at the beginning and end of a line
> >> eh?
> >
> The delimiters \< and \> will delimit the first and last characters of
> a logical word. This syntax can be used in vi or any of the greps.
> To find "the" without also finding all the words in which "the" is
> contained as a string, find \<the\>.

Just a small note: not all systems have a grep version that supports the
\< and \> escapes.  (vi nearly always does).  In these versions of grep,
there is usually a -w (or other) option which does the same thing.  
Altho that's not guaranteed everywhere, either.  As with all things, 
your mileage may vary.
--
asylvain@felix.UUCP (Alvin "the Chipmunk" Sylvain)
========================= Opinions are Mine, Typos belong to /usr/ucb/vi
"We're sorry, but the reality you have dialed is no longer in service.
Please check the value of pi, or see your SysOp for assistance."
{}hplabs!felix!asylvain ================================================