手机
当前位置:查字典教程网 >编程开发 >正则表达式 >截字符串 去除HTML标记
截字符串 去除HTML标记
摘要:

<%

'**************************************************

'函数名:gotTopic

'作 用:截字符串,汉字一个算两个字符,英文算一个字符

'参 数:str ----原字符串

' strlen ----截取长度

'返回值:截取后的字符串

'**************************************************

function gotTopic(str,strlen)

if str="" then

gotTopic=""

exit function

end if

dim l,t,c, i

str=replace(replace(replace(replace(str," "," "),""",chr(34)),">",">"),"<","<")

str=replace(str,"?","")

l=len(str)

t=0

for i=1 to l

c=Abs(Asc(Mid(str,i,1)))

if c>255 then

t=t+2

else

t=t+1

end if

if t>=strlen then

gotTopic=left(str,i) & "…"

exit for

else

gotTopic=str

end if

next

gotTopic=replace(replace(replace(replace(gotTopic," "," "),chr(34),"""),">",">"),"<","<")

end function

'=========================================================

'函数:RemoveHTML(strHTML)

'功能:去除HTML标记

'参数:strHTML --要去除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

set Matches=nothing

End Function

%>

【截字符串 去除HTML标记】相关文章:

正则删除字符串左、右或两端的空格经验总结

自动识别HTML的标记 替换连接

关于HTML及UBB标记的闭合

计算一个字符串在另一字符串中出现的次数函数

EditPlus 正则表达式替换字符串详解

用正则删除不包含某个字符串的行的代码

用Java正则去掉字符串中重复出现的字符

正则基础之 小数点

VBscript 的正则表达式 字符串匹配

JS使用正则去除字符串最后的逗号

精品推荐
分类导航