From: Siep Korteling Date: 2010-03-23T06:07:06+09:00 Subject: Re: splitting text string Joel VanderWerf wrote: > > Another idea: > > $ irb -r scanf > >> "123456789".scanf("%3d%5d%1d") > => [123, 45678, 9] > > (note that the strings are converted to integers for you) "123456789".unpack("A3A5A1") #=> ["123", "45678", "9"] I don't know how to use unpack to deliver integers. Strings may better in this case anyway, because leading zero's survive. -- Posted via http://www.ruby-forum.com/.