From: Gavin Kistner Date: 2005-09-14T23:39:56+09:00 Subject: Re: Quick and dirty word wrapping. On Sep 14, 2005, at 8:26 AM, Erik Terpstra wrote: > str = 'This is a test of the emergency broadcasting services' > str.scan(/(.{1,30})(?:\s+|$)/) > > => [["This is a test of the"], ["emergency broadcasting"], > ["services"]] Nice. Not to golf, but how about simply: str = 'This is a test of the emergency broadcasting services' p str.scan(/.{1,30}\b/) #=> ["This is a test of the ", "emergency broadcasting ", "services"] (No flattening required.) -- (-, /\ \/ / /\/