截字符串 去除HTML標(biāo)記
更新時(shí)間:2006年06月17日 00:00:00 作者:
<%
'**************************************************
'函數(shù)名:gotTopic
'作 用:截字符串,漢字一個(gè)算兩個(gè)字符,英文算一個(gè)字符
'參 數(shù):str ----原字符串
' strlen ----截取長(zhǎng)度
'返回值:截取后的字符串
'**************************************************
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
'=========================================================
'函數(shù):RemoveHTML(strHTML)
'功能:去除HTML標(biāo)記
'參數(shù):strHTML --要去除HTML標(biāo)記的字符串
'=========================================================
Function RemoveHTML(strHTML)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
'取閉合的<>
objRegExp.Pattern = "<.+?>"
'進(jìn)行匹配
Set Matches = objRegExp.Execute(strHTML)
' 遍歷匹配集合,并替換掉匹配的項(xiàng)目
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,"")
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
set Matches=nothing
End Function
%>
'**************************************************
'函數(shù)名:gotTopic
'作 用:截字符串,漢字一個(gè)算兩個(gè)字符,英文算一個(gè)字符
'參 數(shù):str ----原字符串
' strlen ----截取長(zhǎng)度
'返回值:截取后的字符串
'**************************************************
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
'=========================================================
'函數(shù):RemoveHTML(strHTML)
'功能:去除HTML標(biāo)記
'參數(shù):strHTML --要去除HTML標(biāo)記的字符串
'=========================================================
Function RemoveHTML(strHTML)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
'取閉合的<>
objRegExp.Pattern = "<.+?>"
'進(jìn)行匹配
Set Matches = objRegExp.Execute(strHTML)
' 遍歷匹配集合,并替換掉匹配的項(xiàng)目
For Each Match in Matches
strHtml=Replace(strHTML,Match.Value,"")
Next
RemoveHTML=strHTML
Set objRegExp = Nothing
set Matches=nothing
End Function
%>
相關(guān)文章
正則表達(dá)式同時(shí)匹配中英文及常用正則表達(dá)式
這篇文章主要介紹了正則表達(dá)式同時(shí)匹配中英文及常用正則表達(dá)式的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-11-11
正則表達(dá)式從原理到實(shí)戰(zhàn)全面學(xué)習(xí)小結(jié)
這篇文章主要介紹了全面學(xué)習(xí)正則表達(dá)式?-?從原理到實(shí)戰(zhàn),本文全面介紹正則表達(dá)式的語法知識(shí),全面介紹JavaScript中正則表達(dá)式的API,通過實(shí)戰(zhàn),希望能夠幫助大家全面學(xué)習(xí),并啃下前端的難題,需要的朋友可以參考下2022-07-07
15個(gè)常用的javaScript正則表達(dá)式(收藏)
本文是小編收集整理的15個(gè)常用的javascript正則表達(dá)式,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧2017-05-05
精通 JavaScript中的正則表達(dá)式手機(jī)整理 推薦
精通 JS正則表達(dá)式,想學(xué)習(xí)js正則表達(dá)式的朋友非常值得看,整理的比較不錯(cuò)。2009-10-10

