From: "David A. Black" Date: 2008-03-26T06:49:04+09:00 Subject: Re: golf: tabs to bullets Hi -- On Wed, 26 Mar 2008, Martin DeMello wrote: > On Tue, Mar 25, 2008 at 2:16 PM, James Gray wrote: >> >> I didn't really golf it, but my answer is: > > You have a point - I wasn't looking for golf so much as for neat > and/or offbeat approaches to the problem of counting the tabs. Darn, I took you literally :-) def t(s)b='*-ox';s.map{|l|c=l.count("\t") (c-1).times{l.sub!(/\t/,' ')} l.sub(/\t/,b[c-1,1])}end t(some_string) (Thanks to JEG2 for reminding me of count, which I had hypercorrected in my mind into thinking only existed in 1.9 because of Array#count :-) David -- Rails training from David A. Black and Ruby Power and Light: ADVANCING WITH RAILS April 14-17 New York City INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin See http://www.rubypal.com for details and updates!