在提取asp提取数据库内容的时候的时候,如何去掉字段中的【html与图片地址】只提取文字
问题描述:
在提取asp提取数据库内容的时候的时候,如何去掉字段中的【html与图片地址】只提取文字,且只保留10个字符
dailyMsg = RS("calendarText")
if FormatStr(dailyMsg)<>"" then
Response.Write (" <span style='font-size:14px;font-weight:bold;'>" & aCalendarDays((iWeek-1)*7 + iDay) & "<BR></span><A HREF=""" & strPage & """ style='line-height:16px;'>" & Left(nohtml(FormatStr(dailyMsg)),80)
& "
麻烦大神帮我改一下这段代码!!
已知用这种方法可以
但是因为我小白加不进我的代码里面 !!
Function removeHtml(s)
Dim re
Set re = New RegExp
re.Pattern = "<[^>]+>"
re.IgnoreCase = True
re.Global = True
removeHtml=re.Replace(s,"")
End Function
s="w3dev w3dev.cn"
答
Function removeHtml(s)
Dim re
Set re = New RegExp
re.Pattern = "<[^>]+>"
re.IgnoreCase = True
re.Global = True
removeHtml=re.Replace(s,"")
End Function
dailyMsg =removeHtml( RS("calendarText"))'''''''''这样就行了,去掉这个字段的html代码,下面的逻辑自己弄了
if FormatStr(dailyMsg)<>"" then
Response.Write (" <span style='font-size:14px;font-weight:bold;'>" & aCalendarDays((iWeek-1)*7 + iDay) & "<BR></span><A HREF=""" & strPage & """ style='line-height:16px;'>" & Left(nohtml(FormatStr(dailyMsg)),80)
答
你的<和>没有转义。加上反斜杠即可。