asp 用 left 函数截取字符串遇到图片怎么办?

来源:百度知道 编辑:UC知道 时间:2024/06/07 17:04:09
请问各个大虾,.我在用
<%if len(trim(rs("content")))>150 then
response.write(left(trim(rs("content")),150)&"......>>><a href='goto.asp?id="&rs("id")&"' style='color:#628CA6;'>查看全文</a>")
else
response.write(rs("content")) end if%>

函数时遇到图片该怎么办?

先用下面的这个函数去掉HTML标记,然后再截取
Function LoseHtml(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern = "<\/*[^<>]*>"
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
LoseHtml = ClsTempLoseStr
End function

用的时候left(trim(LoseHtml(rs("content"))),150 写成这样就好了

left中第一个参数是字符串,如果是其他类型不就会报错了吗?