28,406
社区成员
发帖
与我相关
我的任务
分享
<%
dim str
str="博客里面文章如果包含有如<a href='xx.asp'>图片</a>,超连接这类标签,如果只是简单的照字符数量截取,如果刚好把标签结尾截掉了,会导致整个页"
str=left(str,31)
response.write("<xmp>"&str&"</xmp>")
%>
str="<p> <font>aaaaaa </font><font>bbbb </font> </p>"
Set objRegExp=New RegExp
Set Reg=New RegExp
objRegExp.IgnoreCase=true
objRegExp.Global=true
objRegExp.Pattern="(<[^>\/]*>)([^<]+)(<\/[^>]+>)"
Reg.IgnoreCase=false
Reg.Global=false
set Matches=objRegExp.Execute(str)
set objRegExp=nothing
num=7'设定截取7个数字
if Matches.Count<>0 then
For Each Match in Matches
if num>0 then
Reg.Pattern="(<[^>\/]*>)"&Match.SubMatches(1)&"(<\/[^>]+>)"
str=Reg.replace(str,"$1"&left(Match.SubMatches(1),num)&"$2")
num=num-len(trim(Match.SubMatches(1)))
response.Write num
end if
next
end if
set Reg=nothing
response.Write str