
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text ml; charset=gb2312" />
<title>利用正則替換生成html,經(jīng)典的,可以用數(shù)組進(jìn)行替換</title>
</head>
<body>
<%
dim container
container="{$1,man,hits,hits$} 456545767 $2,title,man,game$ asfasdfa$3,game,hits,man$"
dim regex,objmatch,matches ' 建立變量。
Set regex = New RegExp ' 建立正則表達(dá)式。
regex.Global = True ' 設(shè)置全局可用性。
regex.IgnoreCase = True ' 設(shè)置是否區(qū)分字符大小寫(xiě)。
regex.Pattern = "\$[\S\s]+?\$" ' 設(shè)置模式
Set matches = regex.Execute(container) '匹配內(nèi)容
For Each objmatch in matches ' 遍歷匹配集合。
'response.Write objmatch.Value & "<br />" '顯示數(shù)組
'response.write split(replace(objmatch.Value,"$",""),",")(0) & "<br />" '顯示數(shù)組的第一個(gè)數(shù)
games=replace(replace(replace(replace(objmatch.Value,"title","標(biāo)題"),"hits","閱讀次數(shù)"),"game","內(nèi) 容"),"man","作者")
'response.write games & "<br>"
response.write split(replace(games,"$",""),",")(0) & "__" & split(replace(games,"$",""),",")(1) & "__" & split(replace(games,"$",""),",")(2) & "__" & split(replace(games,"$",""),",")(3) & "<br>"
Next
response.end
%>
</body>
<html>
呢 稱(chēng): | |
表 情: | |
內(nèi) 容: |
評(píng)論內(nèi)容:不能超過(guò) 1000 字,需審核,請(qǐng)自覺(jué)遵守互聯(lián)網(wǎng)相關(guān)政策法規(guī)。 |
驗(yàn)證碼: | |
您發(fā)布的評(píng)論即表示同意遵守以下條款:
一、不得利用本站危害國(guó)家安全、泄露國(guó)家秘密,不得侵犯國(guó)家、社會(huì)、集體和公民的合法權(quán)益;
二、不得發(fā)布國(guó)家法律、法規(guī)明令禁止的內(nèi)容;互相尊重,對(duì)自己在本站的言論和行為負(fù)責(zé);
三、本站對(duì)您所發(fā)布內(nèi)容擁有處置權(quán)。