日期:2014-05-19  浏览次数:20496 次

文章系统中如何截取前200位?
先说明,不是简单的用SubString(),因为内容可能有HTML代码,截取后要保证完整性
如原文中有 <a   href= "cccc "> fdfd </a> ,不能截取成 <a   href= ",有什么好办法么?


------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME= "Generator " CONTENT= "EditPlus ">
<META NAME= "Author " CONTENT= " ">
<META NAME= "Keywords " CONTENT= " ">
<META NAME= "Description " CONTENT= " ">
<SCRIPT LANGUAGE= "JavaScript ">
<!--
var str= " <p> hello </p> <xx> asdfjalsdjf </xx> ";
var reg=/> ([^ <]{0,5})([^ <]*?) </gim;
alert(str.replace(reg, '> $1 < '));
//-->
</SCRIPT>
</HEAD>

<BODY>

</BODY>
</HTML>
------解决方案--------------------
mark一下.