一段HTML代码组成的页面取其中前300个字_[Asp.Net教程] public static string RemoveHtmlTag (string source) { int debut; int fin; string theTag; debut = source.IndexOf("<"); fin = source.IndexOf(">"); while ((debut >= 0) && (fin > 0)) { debut = source.IndexOf("<"); fin = source.IndexOf(">"); if (debut >= fin) { debut = 0; } fin = fin - debut; theTag = source.Substring (debut, fin + 1); if (theTag != "") { source = source.Replace (theTag,""); } } source = source.Replace(" ", " "); source = source.Replace(">", ">"); source = source.Replace("&", "&"); // Trim return source; } 用SubString () 截取前300个字符
|