From: Harry Kakueki Date: 2009-06-21T17:08:43+09:00 Subject: Re: regular expression gurus--help! On Sun, Jun 21, 2009 at 4:10 PM, timr wrote: > I want all possible three letter sets for a string. Scan does this: > irb> > > But I need: > # >> abc > # >> bcd > # >> cde > # >> def > etc. > > I used to know the secret spell, but forgot it. Does anyone know how > to do this with regular expression > Here is one way to get that result. (But not with a regular expression) Not all 3 letter sets but I think this is the result you are really looking for. str = "abcdefghijkl" puts str.unpack("a3X2"*(str.length-2)) #output abc bcd cde def efg fgh ghi hij ijk jkl Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/ruby/list.html