From: Andrew Johnson Date: 2006-03-14T02:48:45+09:00 Subject: Re: What's the best way to split this kind of string? On Mon, 13 Mar 2006 17:23:56 +0900, Ross Bamford wrote: [snip] > Maybe something like: > > s.scan(/(\d)(\1*)/).map! { |e| e.join } > # => ["111", "22", "3", "1", "33"] > > or: > > s.scan(/0+|1+|2+|3+|4+|5+|6+|7+|8+|9+/) > # => ["111", "22", "3", "1", "33"] Or: s.scan(/((.)\2*)/).transpose[0] Boy, are my fingers glad to save those keystrokes :-) andrew -- Andrew L. Johnson http://www.siaris.net/ They're not soaking, they're rusting! -- my wife (on my dishwashing habits)