<%
function keywords_link(byval str)
dim rs
'解決辦法 來(lái)源 www.021jz.com.cn
set rs=conn.execute("select * from [tag] order by len(keyword) desc")
while not rs.eof
str=p_replace(str,rs("keyword"),""&rs("keyword")&"")
rs.movenext
wend
rs.close
set rs=nothing
keywords_link=str
end function
'解決辦法 避免重複替換 來(lái)源 www.021jz.com.cn
function p_replace(byval content,byval asp,byval htm)
dim Matches,objRegExp,strs,i
strs=content
Set objRegExp = New Regexp'設置配置對(duì)象
objRegExp.Global = True'設置爲全文搜索
objRegExp.IgnoreCase = True
objRegExp.Pattern = "(\]+\>.+?\<\/a\>)|(\]+\>)"'
Set Matches =objRegExp.Execute(strs)
'開始執行配置
'替換正則表達式
i=0
Dim MyArray()
For Each Match in Matches
ReDim Preserve MyArray(i)
MyArray(i)=Mid(Match.Value,1,len(Match.Value))
strs=replace(strs,Match.Value,"<"&i&">")
i=i+1
Next
'沒有正則時(shí)候
if i=0 then
content=replace(content,asp,htm)
p_replace=content
exit function
end if
'特殊字符替換
strs=replace(strs,asp,htm)
'替換回去
for i=0 to ubound(MyArray)
strs=replace(strs,"<"&i&">",MyArray(i))
next
p_replace=strs
end function
%>
來(lái)源上海網頁制作 www.021jz.com.cn