From: Harry Kakueki Date: 2009-06-22T10:29:54+09:00 Subject: Re: regular expression gurus--help! On Sun, Jun 21, 2009 at 9:26 PM, Sebastian Hungerecker wrote: > Am Sonntag 21 Juni 2009 09:10:37 schrieb timr: >> I want all possible three letter sets for a string. Scan does this: >> irb> >> >> >>"abcdefghijkl".scan(...) >> >> # >> abc >> # >> def >> # >> ghi >> # >> jkl >> >> But I need: >> # >> abc >> # >> bcd >> # >> cde >> # >> def >> etc. > >>> "abcdefghijkl".scan(/(.)(?=(..))/).map(&:join) > => ["abc", "bcd", "cde", "def", "efg", "fgh", "ghi", "hij", "ijk", "jkl"] > > HTH, > Sebastian > > I am not the OP, but thanks for that solution. I learned more about regular expressions and relearned something about scan. It did not work on my machine so I changed it to this. p "abcdefghijkl".scan(/(.)(?=(..))/).map{|x| x.join} Is this map(&:join) using 1.9? Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/ruby/list.html