From: lostboard2001@... Date: 2004-12-14T08:42:18+09:00 Subject: Re: Find every location of "th" in string. oh, right, lookaheads: mypatt=/ana/ "banana".scan(/(?=#{mypatt})/) {puts $`.length} Glenn Parker wrote: > Robert Klemme wrote: > >>> "the thin man thinks".scan( /th/ ) { puts $`.length } > > 0 > > 4 > > 13 > > => "the thin man thinks" > > scan doesn't really do that well. > > "banana".scan(/ana/) { puts $`.length } > 1 > => "banana" > > The second overlapping occurence of "ana" is missed.