怎么样字符串过滤

来源:百度知道 编辑:UC知道 时间:2024/06/02 00:42:57
我从数据库提取内容的时候是这些:<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; WORD-BREAK: break-all; TEXT-INDENT: 54pt; LINE-HEIGHT: 25pt; TEXT-ALIGN: left; mso-char-indent-count: 2.25; mso-line-height-rule: exactly; mso-pagination: widow-orphan" align=left><SPAN style="FONT-SIZE: 24pt; FONT-FAMILY: 宋体; mso-bidi-font-family: 宋体; mso-font-kerning: 0pt">亿</SPAN><SPAN style="FONT-SIZE: 12pt; 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><BR> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; WORD-BREAK: break-all; TEXT-INDENT: 27pt; LINE-HEIGHT: 25pt; TEXT-ALIGN: left; mso-char-indent-count: 2.25; mso-line-height-rule: exactly; mso-pa

用正则吧,把<>之间的内容过滤掉,或者只取中文并且不是“宋体”

看见你给我发的信息了,我一点刷新就没了,你重加一下吧,
复杂点的正则:
<script>
function removeTags(html){
// Remove all SPAN tags
html = html.replace(/<\/?SPAN[^>]*>/gi, "" );
// Remove all p tags
html = html.replace(/<\/?P[^>]*>/gi, "" );
// Remove all <br> tags
html = html.replace(/<\/?BR[^>]*>/gi, "" );
// Remove Class attributes
html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
// Remove Style attributes
html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ;
// Remove Lang attributes
html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
// Remove XML elements and declarations
html = html.replace(/<\\?\?xml[^>]*>/gi,