From: Michael Fellinger Date: 2007-03-16T12:22:25+09:00 Subject: Re: Need help converting Perl to Ruby (detecting integers and decimals in strings) On 3/16/07, Paul wrote: > That is brilliant! Thank you, Jon! Of all the good suggestions > posted, I like this one best. You guys all rock! Thanks so much for > the responses. > > Cheers! Paul. =) > > > On Mar 15, 6:22 pm, Jon Garvin wrote: > > rawfields.map { |f| f.to_f.to_s == f ? "%0.2f" % f.to_f : f } rawfields.map{|f| Integer(f) rescue Float(f) rescue f} > > => ["5.67", "0", "3.57", "1.38", "6", "0", "Foo"] > > > > >