From: Stefan Kanev Date: 2009-06-21T17:33:31+09:00 Subject: Re: regular expression gurus--help! --001485f629746224a6046cd79a88 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit I fail to understand what do you mean by "all possible three-letter sets", but it seems there is a method called 'each_cons' that does something in the lines of your discussion. You might find it helpful: http://corelib.rubyonrails.org/classes/Enumerable.html#M002196 On Sun, Jun 21, 2009 at 11:08 AM, Harry Kakueki wrote: > 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 > > --001485f629746224a6046cd79a88--