截字符串 去除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)文章
[js]用JAVASCRIPT正則表達(dá)式限制文本字節(jié)數(shù)的代碼
[js]用JAVASCRIPT正則表達(dá)式限制文本字節(jié)數(shù)的代碼...2007-11-11正則表達(dá)式小腳本(對(duì)輸入內(nèi)容進(jìn)行處理)
該小腳本實(shí)現(xiàn)的是對(duì)輸入框內(nèi)容中取出<img>標(biāo)簽中的src中的內(nèi)容,然后在原來(lái)位置進(jìn)行替換內(nèi)容,然后在去除輸入內(nèi)容中的html標(biāo)簽,空格等操作2016-12-12用JavaScrip正則表達(dá)式驗(yàn)證form表單的方法
這篇文章主要介紹了用JavaScrip正則表達(dá)式驗(yàn)證form表單的方法,需要的朋友可以參考下2017-05-05javascript RegExp multiline多行匹配影響的^$
javascript RegExp multiline多行匹配影響的^$,代碼中有詳細(xì)的注釋,方法大家學(xué)習(xí)。2010-03-03asp match正則函數(shù)使用Matchs實(shí)例
asp matchs函數(shù)提供了對(duì)正則表達(dá)式匹配的只讀屬性的訪問(wèn)。一直都用這個(gè)函數(shù),沒(méi)想到本站竟然沒(méi)有這類文章,汗一個(gè),最近我會(huì)多加一些這樣的文章2008-08-08c# 正則表達(dá)式對(duì)網(wǎng)頁(yè)進(jìn)行有效內(nèi)容抽取
本問(wèn)主要總結(jié)了用正則表達(dá)式對(duì)網(wǎng)頁(yè)進(jìn)行有效內(nèi)容提取的具體實(shí)現(xiàn)方法,并給出了c#代碼2009-03-03