+ -
当前位置:首页 → 问答吧 → 显示html代码时,不显示图片代码

显示html代码时,不显示图片代码

时间:2011-06-13

来源:互联网

我从数据库中读出了一段html代码
如:

<STRONG>Features:</STRONG> <BR>Android 2.2 OS with Android Market and integration with Google applications <BR>Text messaging: Send and receive short text-only messages on your phone. <BR>POP3/IMAP: Support for web-based email from Yahoo!® Mail, Gmail™, Windows Live® Mail, AOL® etc. <BR><BR><STRONG>Specifications: <BR></STRONG>Technology: GSM/GPRS/EDGE/UMTS <BR>Weight: 5.15 ounces <BR>Talk Time: Up to 5 hours <BR><BR><IMG style="BORDER-BOTTOM-COLOR: #000000; BORDER-TOP-COLOR: #000000; BORDER-RIGHT-COLOR: #000000; BORDER-LEFT-COLOR: #000000" border=0 src="http://localhost/ruili/upload/editorfiles/2011.6.13_11.40.0_4335.jpg"><STRONG>Features:</STRONG> <BR>Android 2.2 OS with Android Market and integration with Google applications <BR>


在显示的这些内容时,因为是要做left(xx,100)的代码从简单介绍,但里面含有的图片我不想显示出来.

怎么在显示时,不显示<img ...>这些呢?



作者: 99percent   发布时间: 2011-06-13

VBScript code

<%
s  = "<STRONG>Features:</STRONG> <BR>Android 2.2 OS with Android Market and integration with Google applications <BR>Text messaging: Send and receive short text-only messages on your phone. <BR>POP3/IMAP: Support for web-based email from Yahoo!? Mail, Gmail?, Windows Live? Mail, AOL? etc. <BR><BR><STRONG>Specifications: <BR></STRONG>Technology: GSM/GPRS/EDGE/UMTS <BR>Weight: 5.15 ounces <BR>Talk Time: Up to 5 hours <BR><BR><IMG style=""BORDER-BOTTOM-COLOR: #000000; BORDER-TOP-COLOR: #000000; BORDER-RIGHT-COLOR: #000000; BORDER-LEFT-COLOR: #000000"" border=0 src=""http://localhost/ruili/upload/editorfiles/2011.6.13_11.40.0_4335.jpg""><STRONG>Features:</STRONG> <BR>Android 2.2 OS with Android Market and integration with Google applications <BR>"

Set re = New RegExp
With re
    .Global = True
    .IgnoreCase = False
    .Pattern = "\<IMG [^\>]+?\>"
    s = .Replace(s, "")
End With
response.Write s
%>

作者: hookee   发布时间: 2011-06-13

用正则去除所有的html代码
VB code

'-------------------------------------去除html字符 begin
Function RemoveHTML(strHTML)
  Dim objRegExp, Match, Matches 
  Set objRegExp = New Regexp 
  objRegExp.IgnoreCase = True 
  objRegExp.Global = True 
'取闭合的<> 
  objRegExp.Pattern = "<.+?>" 
'进行匹配 
  Set Matches = objRegExp.Execute(strHTML) 
' 遍历匹配集合,并替换掉匹配的项目 
  For Each Match in Matches 
  strHtml=Replace(strHTML,Match.Value,"") 
  Next 
    RemoveHTML=strHTML 
  Set objRegExp = Nothing 
  set Matches=nothing
End Function



'-------------------------去除HTML---END 


作者: beyond_me21   发布时间: 2011-06-13