下面这个,过滤掉了
怎样保留[img]这个不被过滤。只要这一个。objRegExp.Pattern = "([[a-zA-Z].*?])|([[\/][a-zA-Z].*?])" '
strOutput = objRegExp.Replace(strHtml, "") '将html标签去掉
strOutput = Replace(strOutput, "[", "[") '防止非html标签不显示
strOutput = Replace(strOutput, "]", "]")

解决方案 »

  1.   

    试试这个:/\[\\?(?!img\b)[a-zA-Z].*?\]/
      

  2.   

    是这样吗:objRegExp.Pattern = "(/\[\\?(?!img\b)[a-zA-Z].*?\]/)"
    测试发现全都没过滤了。ubb代码全部显示了。
    我只要[img]不被过滤
      

  3.   

    楼上的意思是
    var objRegExp=/\[\\?(?!img\b)[a-zA-Z].*?\]/;另外你写的是vbscript?
      

  4.   

    这样呢:var html = "[html][img][/html]"
    html = html.replace(/\[\/?(?!img)[^\]]*\]/g,"");
    alert(html);
      

  5.   

    还是不对啊。谢谢高手们。我的程序是这样的:Function delHtml(strHtml) '函数名
    Dim objRegExp, strOutput
    Set objRegExp = New Regexp 
    objRegExp.IgnoreCase = True 
    objRegExp.Global = True 
    objRegExp.Pattern = "([(?!img\])[A-Z].*?])|([[\/][a-z].*?])" 
    strOutput = objRegExp.Replace(strHtml, "") 
    strOutput = Replace(strOutput, "[", "[") 
    strOutput = Replace(strOutput, "]", "]") 
    delHtml = strOutput
    Set objRegExp = Nothing
    End Function
    ------------------------------------------
    Content=delHtml(Rs("Content"))
    parent=Rs("parent")
    if instr(Content,"[img]")>0 Then 
    Content="分享了图片"
    end if
      

  6.   

    由于 delHtml 过滤掉了全部ubb代码。导致我下面的 if instr(Content,"[img]")>0 Then   判断没用。
      

  7.   

    <script type="text/vbscript">
    strHtml = "[a][b][b]test[\b]"
    Set objRegExp = new RegExp
    objRegExp.Pattern = "\[\\?(?!img\b)[a-zA-Z].*?\]" '
    objRegExp.Global = True
    strOutput = objRegExp.Replace(strHtml, "") '将html标签去掉
    MsgBox strOutput
    </script>