Possible Duplicate:
How to split string preserving whole words?
I have the following string:
string s = "The Electors shall meet in their respective states to vote by ballot for President and Vice-President.";
I want to take the first 60 characters and split them into two separate strings each of 30 characters or less. Each string must start with a whole word (no partial word, nor space). So this is the desired result:
string s1 = "The Electors shall meet in"; // 26 characters
string s2 = "their respective states to vot"; // 30 characters
Thank you.
1 Answer