用户发新闻时经常粘贴word里的东西,HTML代码见最下面
新闻列表页要取这样的内容的前200个字,如何过滤.从网上搜的只能过滤一般的html标签,不能过滤如
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />这样的,
截取前200个字符时可能会形成断位,如下也要过滤掉
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office
这会导致新闻列表页表格混乱等.时间急,请大师们帮忙!
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">浸四氟苎麻盘根、高水基盘根、高档油浸棉纱盘根、普通油浸棉纱盘根、<SPAN lang=EN-US><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></SPAN></P>  <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">纤维类盘根应用广泛,<SPAN lang=EN-US>&nbsp;</SPAN>根据各自不同的优良性能可用于</SPAN

解决方案 »

  1.   

    <[^>]+>|</[^>]+>public String clearHtml(String str){      Pattern p = Pattern.compile("<[^>]+>|</[^>]+>",Pattern.CASE_INSENSITIVE );
         
        Matcher m = p.matcher(str);
        
      return m.replaceAll("");
         
         }
      

  2.   

    请问你用的是在线FCKeditor编辑工具吗
      

  3.   

    用的是FCKeditor,FreeTextBox <[^>]+>|</[^>]+>,太彻底了,
    内容简介必须要支持加亮红,下划线等效果,所以必须指定只过滤<?xml...的.
    谢谢大家,我也试试