Im looking to split a string with HTML tags into two sections. 1st section with a limited number of characters, the next section with the remainder of the original string.
Im currently using the following in order to split the string:
public static string SplitWord(string x, int length)
if (x.Length > length)
x = x.Substring(0, length);
string1 = SplitWord(string, 1000);
string2 = string.Substring(1000);
With my current solution, on the odd occasion it will split up a html tag. For example:
string = "<di"
string1 = "v>";
string = "<div>"
string1 = "</div>";
Is there a way of diving up a string into two parts, but making sure it does after a closing html tag.
string = "<div></div>"
string1 = "";