I have a db field that contains HTML. Now I want to have the first 100 some
characters of this field without ending up with invalid HTML. This means it
shouldn't split in the middle of a hyperlink or bold text. Ideally it would
even split in the middle and add the end tag but that might be hard.
Has anybody tackled this problem and what was your approach? I'm curious
what creative ideas you have to this problem.
Here is what I have until now to make sure I don't split the string in the
middle of a sentence or word:
public string SpaceFinder(string input)
{
if (input.Length > 110)
input = input.Substring(0,110);
if (input.LastIndexOf(".") != -1)
input = input.Substring(0,input.LastIndexOf(".")+1);
else if (input.LastIndexOf(" ") != -1)
input = input.Substring(0,input.LastIndexOf(" ")) + "..";
return input;
}
thanks,
Yannick Smits
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/