Split large text string into variable length strings without breaking words and keeping linebreaks a
Posted
by Frank
on Stack Overflow
See other posts from Stack Overflow
or by Frank
Published on 2010-05-11T22:58:41Z
Indexed on
2010/05/12
14:14 UTC
Read the original article
Hit count: 366
I am trying to break a large string of text into several smaller strings of text and define each smaller text strings max length to be different. for example:
"The quick brown fox jumped over the red fence. The blue dog dug under the fence."
I would like to have code that can split this into smaller lines and have the first line have a max of 5 characters, the second line have a max of 11, and rest have a max of 20, resulting in this:
Line 1: The Line 2: quick brown Line 3: fox jumped over the Line 4: red fence. Line 5: The blue dog Line 6: dug under the fence.
All this in C# or MSSQL, is it possible?
© Stack Overflow or respective owner