From: Gennady Bystritsky Date: 2009-03-05T12:24:55+09:00 Subject: Re: Cut a string each 80 character > -----Original Message----- > From: Kyle Schmitt [mailto:kyleaschmitt@gmail.com] > Sent: Wednesday, March 04, 2009 6:45 PM > To: ruby-talk ML > Subject: Re: Cut a string each 80 character > > On Wed, Mar 4, 2009 at 8:06 PM, Guillaume Loader > wrote: > > Ooops! > > Replace "each" by "every" > > > > Sorry! > > - Show quoted text - > > -- > > Posted via http://www.ruby-forum.com/. > > > > > > I'm thinking you want scan. > > string.scan(/.{8}/) > > > You may need to adjust the regex a little, but that should match 8 > charicters at a time... > I think if the length isn't a multiple of 8 it may just ignore the > last bunch of chars... but you get the idea For that not to be ignored, use {1,8} instead of just {8}. As a minor note, OP wanted 80, not 8 ;-) Gennady. > > edit the regex as needed. > > PS: Scan is _awesome_ when you need to do some quick an dirty log > analysis > data=File.read(foo).scan(regex)