From: Robert Klemme Date: 2004-10-11T23:34:37+09:00 Subject: Re: string replacement "J.Lang" schrieb im Newsbeitrag news:1097503642.10233.38.camel@tux... > we need to replace a whitespace with a
if the string is longer > then 30 chars (next whitespace after 30 chars) So you don't want to replace all spaces but only insert a line break every ~30 characters. > does someone have a idea to programm this in ruby? How about this: str.gsub(/(.{30})\s+/, '\\1
') Alternatively you can use gsub! if you want to modify the string in place. Kind regards robert