我想问下p怎么给关键词添加超链接呢
asp想给指定的关键词添加超链接,其实就是替换。青岛星网下面跟大家分享一个替换函数。
<%
'=========================================
'参数说明:
'str 原字符串
'patrn 要替换的字符串(正则表达式)
'replStr 要替换成的字符串
'Ignor 是否区分大小写(1不区分,0区分)
'=========================================
Function ReplaceReg(str,patrn,replStr,Ignor)
Dim regEx '建立变量
If Ingor=1 Then Ingor=true else Ingor=false
Set regEx = New RegExp '建立正则表达式
regEx.Pattern = patrn '设置模式
regEx.IgnoreCase = Ignor '设置是否区分大小写
regEx.Global=True
ReplaceReg = regEx.Replace(str,replStr) ' 执行替换
End Function
'把www.xxx.com自动替换为:<a href=""http://www.qdxw.net"">www.qdxw.net</a>
Response.Write(ReplaceReg("青岛星网www.xxx.com","www\.xxx\.com","<a href=""http://www.qdxw.net"">www.qdxw.net</a>",1))
%>
