From: botp Date: 2007-08-12T02:00:10+09:00 Subject: Re: Split a string based on change of character On 8/11/07, dblack@rubypal.com wrote: > > s = "ZBBBCZZ" > > x = s.split('').group_by{|x| x}.entries > > > > or possibly to > > > > x = s.split('').group_by.entries > > I'm going to have to get special glasses that can read invisible > ink.... :-) whoops, sorry =) that should be fr x = s.split('').group_by{|x| x}.entries.map{|x| x.join} to x = s.split('').group_by.entries.map{|x| x.join} i assume that group_by without a block would group the elements by themselves. maybe i should name it group not group_by :) kind regards -botp