写了一个:
<script>
   var Lb1String="L<table></table>abel";
   Lb1String = Lb1String.replace(/<[^>]*>/g, '');
</script>输出却是:L&lt;table&gt;&lt;/table&gt;abel; 这是为什么呀?该怎样写呢?

解决方案 »

  1.   

    function delHtmlTag(str)
    {
    return str.replace(/<[^>]+>/g,"");
    }
      

  2.   

      Function   ClearHtml(Content)   
      Content=Zxj_ReplaceHtml("&#[^>]*;",   "",   Content)   
      Content=Zxj_ReplaceHtml("</?marquee[^>]*>",   "",   Content)   
      Content=Zxj_ReplaceHtml("</?object[^>]*>",   "",   Content)   
      Content=Zxj_ReplaceHtml("</?param[^>]*>",   "",   Content)   
      Content=Zxj_ReplaceHtml("</?embed[^>]*>",   "",   Content)   
      Content=Zxj_ReplaceHtml("</?table[^>]*>",   "",   Content)   
      Content=Zxj_ReplaceHtml("&nbsp;","",Content)   
      Content=Zxj_ReplaceHtml("</?tr[^>]*>",   "",   Content)   
      Content=Zxj_ReplaceHtml("</?th[^>]*>","",Content)   
      Content=Zxj_ReplaceHtml("</?p[^>]*>","",Content)   
      Content=Zxj_ReplaceHtml("</?a[^>]*>","",Content)   
      Content=Zxj_ReplaceHtml("</?img[^>]*>","",Content)   
      Content=Zxj_ReplaceHtml("</?tbody[^>]*>","",Content)   
      Content=Zxj_ReplaceHtml("</?li[^>]*>","",Content)   
      Content=Zxj_ReplaceHtml("</?span[^>]*>","",Content)   
      Content=Zxj_ReplaceHtml("</?div[^>]*>","",Content)   
      Content=Zxj_ReplaceHtml("</?th[^>]*>",   "",   Content)   
      Content=Zxj_ReplaceHtml("</?td[^>]*>",   "",   Content)   
      Content=Zxj_ReplaceHtml("</?script[^>]*>",   "",   Content)   
      Content=Zxj_ReplaceHtml("(javascript|jscript|vbscript|vbs):",   "",   Content)   
      Content=Zxj_ReplaceHtml("on(mouse|exit|error|click|key)",   "",   Content)   
      Content=Zxj_ReplaceHtml("<\\?xml[^>]*>",   "",   Content)   
      Content=Zxj_ReplaceHtml("<\/?[a-z]+:[^>]*>",   "",   Content)   
      Content=Zxj_ReplaceHtml("</?font[^>]*>",   "",   Content)   
      Content=Zxj_ReplaceHtml("</?b[^>]*>","",Content)   
      Content=Zxj_ReplaceHtml("</?u[^>]*>","",Content)   
      Content=Zxj_ReplaceHtml("</?i[^>]*>","",Content)   
      Content=Zxj_ReplaceHtml("</?strong[^>]*>","",Content)   
      ClearHtml=Content   
      End   Function   
        
      Function   Zxj_ReplaceHtml(patrn,   strng,content)   
      IF   IsNull(content)   Then   
      content=""   
      End   IF   
      Set   regEx   =   New   RegExp '   建立正则表达式。   
      regEx.Pattern   =   patrn '   设置模式。   
      regEx.IgnoreCase   =   true             '   设置忽略字符大小写。   
      regEx.Global   =   True '   设置全局可用性。   
      Zxj_ReplaceHtml=regEx.Replace(content,strng) '   执行正则匹配   
      End   Function   
      %>