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.
http://farechase.yahoo.com
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 -%>
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…