From: William James Date: 2006-03-13T18:58:45+09:00 Subject: Re: What's the best way to split this kind of string? Sam Kong wrote: > Hi! > > I'm trying to make a routine to make a Morris Number Sequence. > (http://www.ocf.berkeley.edu/~stoll/number_sequence.html) > I need to split a string in the following way, for example. > > "111223133" => ["111", "22", "3", "1", "33"] > > I can loop thru the string by each character, comparing with the > previous character. > But is there a quick and easy way? > Probably a regular expression? > > Thanks. > > Sam "111223133".scan(/(.)(\1*)/).map{|x|x.join}