正則的一些寫法

str1="<a class=""srPatentName"" id='patentID=DDD-2454'></a><a class=""srPatentName"" id='patentID=ASSS-4444'></a><a class=""srPatentName"" id='patentID=KKK-23123'></a><a class=""cClass"" id='c1'></a>"

sub replaceimg(str)
dim  re
set re = new RegExp
re.Pattern = "<a(.*?)id='(.*?)'></a>"

re.Global = true
'response.write re.replace(str,"$1")

Set Matches = re.Execute(str)

for each match in matches
response.write match.SubMatches(1)
next

end sub

 

 

 

 

str1="<P><P><IMG src=""/uploadimages/200908/20090814105325.gif"" border=0><center><IMG src=""/uploadimages/200908/20090814105325.gif"" border=0></center></P>"

function replaceimg(str)
dim  re
set re = new RegExp
re.Pattern = "<IMG([^>]*)border=0>"
re.Global = true
replaceimg=re.replace(str,"[IMG$1]")

end function
t1=replaceimg(str1)
t2=htmlfilter(t1)
'response.write t2

function replaceimgre(str)

dim re
set re = new RegExp
re.Pattern = "/[IMG([^/]]*)/]"
re.Global = true
replaceimgre=re.replace(str,"$1")

end function

t3=replaceimgre(t2)

response.write t3

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章