asp描述标签如何截取文章摘要
asp程序下如何截取文章中的前面一部分文字作为摘要呢?例如:哎,不会如何调用你们说的那些函数到当前页,把你们说的函数放到function.asp后,下面怎么做?比如<me...
asp程序下如何截取文章中的前面一部分文字作为摘要呢?例如:
哎,不会如何调用你们说的那些函数到当前页,把你们说的函数放到function.asp后,下面怎么做?比如<meta name="Description" content="这里填什么调用标签?"> 展开
哎,不会如何调用你们说的那些函数到当前页,把你们说的函数放到function.asp后,下面怎么做?比如<meta name="Description" content="这里填什么调用标签?"> 展开
3个回答
展开全部
给你一个我自己总结的一个函数吧,支持中英文混搭的,在文字排版上非常好用的
Function s_len(str1,num_n,sort_d)
'str1为字符串,num_n为要显示的字数,sort_d为结尾的符号如...或~
'str1=RecovertHTML(str1)
str1=replace(str1, "<","<")'还原字符串
str1=replace(str1, ">", ">")
str1=replace(str1,""",chr(34))
str1=replace(str1,"'",chr(39))
'str1=replace(str1, "<br />",vbCrLf)
str1=replace(str1, " "," ")
str1=replace(str1, " "," ")
length=len(str1)
dim chinese,ii
chinese=0
for ii=1 to length
if asc(mid(str1,ii,1))<1 or asc(mid(str1,ii,1))>255 then
chinese=chinese+1
end if
if chinese+ii>num_n then '超过规定的数,就退出循环
exit for
end if
next
s_len=left(str1,ii)
kk=right(s_len,1)
if asc(mid(str1,1,1))<1 or asc(mid(str1,1,1))>255 then '如果算完后最后一个是双字节数,则总数再减一
iii=ii-1
s_len=left(str1,iii)
end if
if chinese+ii>num_n then '如果标题大于规定的字数时后面加...
s_len=s_len+sort_d
end if
s_len=Replace(s_len,"<br />", " ")
s_len=Replace(s_len,"<br>", " ")
s_len=Replace(s_len,"<","<")
s_len=Replace(s_len,">",">")
s_len=Replace(s_len," ", " ")
s_len=Replace(s_len,chr(34),""")
s_len=Replace(s_len,chr(39),"'")
s_len=Replace(s_len,vbCrLf,"<br />")
'response.write "字符串:" & str1 & "<br>"
'response.write "s_len(command)=" & s_len & "<br>"
'response.write "length+chinese字数为:" & length+chinese & "<br>"
'response.write "chinese+ii=" & chinese+ii & "<br>"
'response.write "ii=" & ii & "<br>"
'response.write "其中中文" & chinese & "个,非中文" & length-chinese & "个<br>"
End Function
Function s_len(str1,num_n,sort_d)
'str1为字符串,num_n为要显示的字数,sort_d为结尾的符号如...或~
'str1=RecovertHTML(str1)
str1=replace(str1, "<","<")'还原字符串
str1=replace(str1, ">", ">")
str1=replace(str1,""",chr(34))
str1=replace(str1,"'",chr(39))
'str1=replace(str1, "<br />",vbCrLf)
str1=replace(str1, " "," ")
str1=replace(str1, " "," ")
length=len(str1)
dim chinese,ii
chinese=0
for ii=1 to length
if asc(mid(str1,ii,1))<1 or asc(mid(str1,ii,1))>255 then
chinese=chinese+1
end if
if chinese+ii>num_n then '超过规定的数,就退出循环
exit for
end if
next
s_len=left(str1,ii)
kk=right(s_len,1)
if asc(mid(str1,1,1))<1 or asc(mid(str1,1,1))>255 then '如果算完后最后一个是双字节数,则总数再减一
iii=ii-1
s_len=left(str1,iii)
end if
if chinese+ii>num_n then '如果标题大于规定的字数时后面加...
s_len=s_len+sort_d
end if
s_len=Replace(s_len,"<br />", " ")
s_len=Replace(s_len,"<br>", " ")
s_len=Replace(s_len,"<","<")
s_len=Replace(s_len,">",">")
s_len=Replace(s_len," ", " ")
s_len=Replace(s_len,chr(34),""")
s_len=Replace(s_len,chr(39),"'")
s_len=Replace(s_len,vbCrLf,"<br />")
'response.write "字符串:" & str1 & "<br>"
'response.write "s_len(command)=" & s_len & "<br>"
'response.write "length+chinese字数为:" & length+chinese & "<br>"
'response.write "chinese+ii=" & chinese+ii & "<br>"
'response.write "ii=" & ii & "<br>"
'response.write "其中中文" & chinese & "个,非中文" & length-chinese & "个<br>"
End Function
展开全部
首先对文章内容进行去除HTML代码,
再取前80个字符
给你个参考:
''去除HTML标签
Function RemoveHTMLTag(str)
If IsNull(str) Or str="" Then
RemoveHTMLTag = ""
Else
Set reg = New RegExp
reg.Pattern = "<[^<>]*>"
reg.Global = true
RemoveHTMLTag =reg.Replace(str,"")
Set reg = Nothing
End If
End Function
strContent = Left(RemoveHTMLTag(strContent),80)
再取前80个字符
给你个参考:
''去除HTML标签
Function RemoveHTMLTag(str)
If IsNull(str) Or str="" Then
RemoveHTMLTag = ""
Else
Set reg = New RegExp
reg.Pattern = "<[^<>]*>"
reg.Global = true
RemoveHTMLTag =reg.Replace(str,"")
Set reg = Nothing
End If
End Function
strContent = Left(RemoveHTMLTag(strContent),80)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<% if Len(rs("文章内容"))>80 then
Response.Write Left(rs("文章内容"),77)&"..."
Else
Response.Write rs("文章内容")
End If%>
Response.Write Left(rs("文章内容"),77)&"..."
Else
Response.Write rs("文章内容")
End If%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询