Split string into multiple lines
Posted
by RememberME
on Stack Overflow
See other posts from Stack Overflow
or by RememberME
Published on 2010-03-16T19:51:30Z
Indexed on
2010/03/16
20:11 UTC
Read the original article
Hit count: 204
I have a long string of comments that I'd like to split into multiple lines.
It's currently displayed as <%= Html.Encode(item.important_notes) %>
I've played with using .Substring
to split it, but can't figure out how to prevent it from splitting in the middle of a word. Instead of characters 1-100 on line 1 and 101-200 on line 2, I'd like to do something like character 1 through the last space before character 100 on line one. That character through the last space before the next 100 characters on line 2, etc.
What is the best way to do this?
EDIT: using ASP.NET-MVC
© Stack Overflow or respective owner