From: Jamis Buck Date: 2004-12-12T09:23:00+09:00 Subject: Re: Find every location of "th" in string. On 09:07 Sun 12 Dec , William James wrote: > Find location of every "th" in "the thin man thinks". > > In Icon: > > every write(find("th", "the thin man thinks")) > > In Ruby: > > s='the thin man thinks' > t='th' > (0...s.size).each{|x| puts x if s[x,t.size]==t} > > Is there a better way? Next time I'll read the code sippets better. :) The following, I think, will do what you are asking: "the thin man thinks".scan( /th/ ) { p $~.begin(0) } - Jamis -- Jamis Buck jgb3@email.byu.edu http://www.jamisbuck.org/jamis