asp截取安符

来源:百度知道 编辑:UC知道 时间:2024/06/08 14:32:50
有人在吗,问个关于ASP截取字符的问题,数据库是ACCESS的。
<%=left(rs24("mc"),20)%>,我是这样截取的,要是数据库的那条记录全部是数字那没什么问题,可现在客户有些内容是直接从网上复制的,就会出现一些

P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-or

这种代码,当我截取20个字符的话,我的版本面就会出现排版混乱,这个问题,请问下,该怎么解决了 !!!急

知道的要指点下啊,先谢了。

先过滤字符串中的html代码。然后再截取。
过滤的函数:
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
End Function

用正则把所有HTML过滤掉后再截取~~~

Function FilterHtml(Byval ConStr)
Dim Re
Set Re = new RegExp
Re.IgnoreCase = True
Re.Global = True
Re.Pattern = "<([^>])*>"
ConStr = Re.Replace(ConStr,"")
Re.Pattern = "</([^>])*>"
ConStr = Re.Replace(ConStr,"")
replaceHtml = ConStr
Set Re = Nothing
End Function