I would like to be able to split a string into several parts if it exceeds a certain number of characters(e.g 100). It is relatively easy, but the tricky part is that I want to split it only after a space so that it doesn’t cut off some word, but rather cuts it on a space character. So the logic would be – if it is more than ~95 chars, split it at the next space character and keep doing it in a loop. Any suggestions on how to implement this?
Thank you.
Use an override of
string.LastIndexOf: this oneYou can call
mystring.LastIndexOf(' ', startIndex, endIndex). If you use indexes0and100, you can get the last space in the first 100 characters.