I will try to explain what I am looking for as much as possible. I am currently using this code to break a line every x number of characters.
public static string SpliceText(string text, int lineLength) { return Regex.Replace(text, "(.{" + lineLength + "})", "$1" + Environment.NewLine); }
This works fine, but often it breaks every number x and, obviously, sometimes breaks a word. Is it possible for the code to check if it violates the word in the middle of the word, and if it does not break at all, but now check if the first character after the break is a space and removes it, if so?
I know that I ask a lot, but thanks in advance!
source share