国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > regex > 正文

截字符串 去除HTML標記

2020-01-20 22:31:11
字體:
來源:轉載
供稿:網友
<%
'**************************************************
'函數名: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
%>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 莒南县| 楚雄市| 商水县| 通榆县| 抚州市| 修水县| 瑞昌市| 泾阳县| 响水县| 平安县| 宁南县| 彭州市| 明水县| 内江市| 曲靖市| 大埔区| 焉耆| 平潭县| 蓝山县| 平昌县| 扶沟县| 巴马| 尚义县| 定日县| 武穴市| 福安市| 电白县| 韶山市| 榆中县| 开原市| 铜山县| 文昌市| 邛崃市| 济南市| 桓台县| 定边县| 原平市| 荆门市| 普安县| 彭山县| 扎鲁特旗|