I need to split string on words and each line should have 25 characters. for example:
string ORIGINAL_TEXT = "Please write a program that breaks this text into small chucks. Each chunk should have a maximum length of 25 "
output should be:
"Please write a program",
"that breaks this text",
"into small chucks. Each",
"chunk should have a",
"maximum length of 25"
I tried using substring - but it is breaking words like
"Please write a program th" - wrong
"Please write a program" - correct
Please write a program - is only 23 characters, it can take more 2 characters but it would break the word that.
string[] splitSampArr = splitSamp.Split(',', '.', ';');
string[] myText = new string[splitSampArr.Length + 1];
int i = 0;
foreach (string splitSampArrVal in splitSampArr)
{
if (splitSampArrVal.Length > 25)
{
myText[i] = splitSampArrVal.Substring(0, 25);
i++;
}
myText[i] = splitSampArrVal;
i++;
}
.(and,and;) but as the output, you say you need"into small chucks. Each"with a dot inside?