From: 7stud -- Date: 2009-07-22T05:16:59+09:00 Subject: Re: String spliting and inclusion Stuart Clarke wrote: > Hi all, > > I am having trouble working out some logic for my problem. I basically > have a long string (320 characters) and I want to split into smaller > strings no longer than 50 characters in length. At present I have the > following regex: > > data = "big long string" > > puts data.scan(/{50}/) > error: invalid regular expression; there's no previous pattern, to which '{' would define cardinality data =< 0 chunks << curr_chunk.join() end p chunks chunks.each do |chunk| puts chunk.length end -- Posted via http://www.ruby-forum.com/.