Word_wrap with hard break


#1

How can I force word_wrap to break text like this?

<% @text=‘abcdefghijklmnopqrstuvwxyz’ %>

<%= word_wrap(@text, 10) %>

It appears to currently only break on space characters.

thanks
csn


Yahoo! FareChase: Search multiple travel sites in one click.


#2

CSN wrote:

How can I force word_wrap to break text like this?

<% @text=‘abcdefghijklmnopqrstuvwxyz’ %>

<%= word_wrap(@text, 10) %>

It appears to currently only break on space characters.

Possibly ever-so-slight overkill:

<% require ‘strscan’
scan = StringScanner.new(@text)
while b = a.scan(/.{0,10}/) -%>
<%= b %>

<% end -%>


#3

Alex Y. wrote:

Possibly ever-so-slight overkill:

<% require ‘strscan’
scan = StringScanner.new(@text)
while b = a.scan(/.{0,10}/) -%>
<%= b %>

<% end -%>

Sod. That was stupid. I meant this:

<% require ‘strscan’
scanner = StringScanner.new(@text)
while line = scanner.scan(/.{0,10}/) -%>
<%= line %>

<% end -%>

Apologies for the confusion…