Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!uhog.mit.edu!bloom-beacon.mit.edu!news.starnet.net!wupost!news.utdallas.edu!corpgate!bcarh189.bnr.ca!nott!cunews!freenet.carleton.ca!FreeNet.Carleton.CA!aa881
From: aa881@FreeNet.Carleton.CA (Guy Marentette)
Subject: Re: "ST String nextWord method?"
Message-ID: <DAA9rn.H63@freenet.carleton.ca>
Sender: aa881@freenet3.carleton.ca (Guy Marentette)
Reply-To: aa881@FreeNet.Carleton.CA (Guy Marentette)
Organization: The National Capital FreeNet
References: <3rqirv$pui@hermes.dna.mci.com>  
Date: Fri, 16 Jun 1995 20:47:47 GMT
Lines: 34

 (7231780@mcimail.com) writes:
> I am going through all this effort to write a method which parses
> a string to get the next word.  It's hard for me to believe that
> a function so common is not already developed somewhere.  But look
> high and low, I can't find it.
> 
> s := 'The quick, lazy brown fox'.
> word := s nextWord.
> 
> "s" is a ByteString.
> 
> I want "word" to be "The" in the first execution, "quick" second,
> "lazy" third, "brown" fourth, and "fox" fifth.  The nextWord 
> function needs to not only delimit spaces, but commas, periods,
> etc. as well.  "Fox" needs to be delimited by "atEnd".
> 
> I searched VW class libraries for *word* and *next* with no success.
> 
> Anything invented already I can reuse?
> 
> Thanks in advance.
> 
> Wes

In Digitalk smalltalk, I stream over the string and use the stream's
nextWord method as follows:

aStream:= ReadStream on:'This is a test'.
aStream nextWord
--
---------------------------------------------
Guy Marentette
aa881@Freenet.carleton.ca
Ottawa, Canada
