using System . Text . RegularExpressions;
public string HtmlSubstring( string AHtml , int ALength )
{
string vReturn = "" ;
int vLength = 0 ; //
int vFlag = 0 ; //
foreach ( char vChar in AHtml)
{
switch (vFlag)
{
case 0 : //
if (vChar == '<' )
{
vReturn += vChar;
vFlag = 1 ;
}
else
{
vLength ++ ;
if (vLength <= ALength)
vReturn += vChar;
}
break ;
case 1 : //
if (vChar == '>' ) vFlag = 0 ;
vReturn += vChar;
break ;
}
}
#region
string vTemp;
do
{
vTemp = vReturn;
vReturn = Regex . Replace(vReturn, @"<[^>^\/]*?><\/[^>]*?>" , "" ,
RegexOptions . IgnoreCase);
}
while (vTemp != vReturn);
#endregion
return vReturn;
}