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