• Post Reply Bookmark Topic Watch Topic
  • New Topic

Breaking up text in lines  RSS feed

 
Barry Brashear
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a String of text that I want to break up into String arrays with a
maximum number of characters at 35. What is the best way to do this?

Thanks.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this like wordwrapping? Here's an approach I've used ...

There leaves out some details ... what if a single word is longer than max? And get rid of that extra blank I put at the front of each line.

An alternate algorithm that does fewer loops ...

I never used that one because I had to remove redundant spaces between words and put two spaces after sentences like old timey typists.

Was that the right problem?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!