- ·上一篇文章:asp网站实现防小偷抓取的策略和方法
- ·下一篇文章:利用asp获取客户端真实的IP地址
给字符串中的网址加上超连接
<
%
Function 
regExReplace(sSource,patrn, 
replStr) 
Dim 
regEx, 
str1 
str1 
= 
sSource 
Set 
regEx 
= 
New 
RegExp 
regEx.Pattern 
= 
patrn 
regEx.IgnoreCase 
= 
True 
regEx.Global 
= 
True 
regExReplace 
= 
regEx.Replace(str1, 
replStr) 
End 
Function
Function 
RegExpTest(strng,s)
strng1=strng
Dim 
regEx, 
Match, 
Matches 
 
 
&
#39
 
建立变量。
Set 
regEx 
= 
New 
RegExp 
 
 
&
#39
 
建立正则表达式。
regEx.Pattern 
= 
s 
 
 
&
#39
 
设置模式。
regEx.IgnoreCase 
= 
True 
 
 
&
#39
 
设置是否区分大小写。
regEx.Global 
= 
True 
 
 
&
#39
 
设置全局替换。
Set 
Matches 
= 
regEx.Execute(strng) 
 
 
&
#39
 
执行搜索。
For 
Each 
Match 
in 
Matches 
 
 
&
#39
 
遍历 
Matches 
集合。
strng1=regExReplace(strng1,Match.value,"
<
a 
href="
"
"
&
#38
Match.value&
#38
"
"
"
 
target="
"
_blank"
"
>
"
&
#38
Match.Value&
#38
"
<
/a>
"
)
Next
RegExpTest 
= 
strng1
end 
Function
str="
http://www.yahoo.com.cn雅虎http://www.sina.com.cn新浪http://hao123.com好123"
s="
((http:[/][/]|www.)([a-z]|[A-Z]|[0-9]|[/.]|[~])*)"
response.write 
RegExpTest(str,s)
 
 
%>
%
Function 
regExReplace(sSource,patrn, 
replStr) 
Dim 
regEx, 
str1 
str1 
= 
sSource 
Set 
regEx 
= 
New 
RegExp 
regEx.Pattern 
= 
patrn 
regEx.IgnoreCase 
= 
True 
regEx.Global 
= 
True 
regExReplace 
= 
regEx.Replace(str1, 
replStr) 
End 
Function
Function 
RegExpTest(strng,s)
strng1=strng
Dim 
regEx, 
Match, 
Matches 
 
 
&
#39
 
建立变量。
Set 
regEx 
= 
New 
RegExp 
 
 
&
#39
 
建立正则表达式。
regEx.Pattern 
= 
s 
 
 
&
#39
 
设置模式。
regEx.IgnoreCase 
= 
True 
 
 
&
#39
 
设置是否区分大小写。
regEx.Global 
= 
True 
 
 
&
#39
 
设置全局替换。
Set 
Matches 
= 
regEx.Execute(strng) 
 
 
&
#39
 
执行搜索。
For 
Each 
Match 
in 
Matches 
 
 
&
#39
 
遍历 
Matches 
集合。
strng1=regExReplace(strng1,Match.value,"
<
a 
href="
"
"
&
#38
Match.value&
#38
"
"
"
 
target="
"
_blank"
"
>
"
&
#38
Match.Value&
#38
"
<
/a>
"
)
Next
RegExpTest 
= 
strng1
end 
Function
str="
http://www.yahoo.com.cn雅虎http://www.sina.com.cn新浪http://hao123.com好123"
s="
((http:[/][/]|www.)([a-z]|[A-Z]|[0-9]|[/.]|[~])*)"
response.write 
RegExpTest(str,s)
 
 
%>
给字符串中的网址加上超连接