If you want the ending token to be excluded, you can use this:
string test = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head runat=\"server\"><title></title></head><body><table> <tr><td>test</td></tr> </table><div id=\"13\"> </body> test test test test </html>";
string result = test.Split(new string[] { "<div id=\"13\">"}, StringSplitOptions.None).FirstOrDefault();
If you want the ending token to be included, you can use this:
string test = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head runat=\"server\"><title></title></head><body><table> <tr><td>test</td></tr> </table><div id=\"13\"> </body> test test test test </html>";
string endString = "<div id=\"13\">";
string result = test.Substring(0, test.IndexOf(endString) + endString.Length);
Beware that string literals must be enclosed in double quote characters and not apostrophes, and quote characters inside them must be escaped by preceding them with a \
.
Also note that in my code I haven't done any type of validation, I leave that up to you. :)