ASP VBSCRIPT 正则表达式之 替换 URL 与 EMAIL 地址为热链接zz - 飘凌大杂烩
飘凌大杂烩电脑网络手机数码编程技术ASP VBSCRIPT 正则表达式之 替换 URL 与 EMAIL 地址为热链接zz
    
 
ASP VBSCRIPT 正则表达式之 替换 URL 与 EMAIL 地址为热链接zz
发起人:piaoling  回复数:0  浏览数:5558  最后更新:2009/6/5 10:24:27 by piaoling

选择查看 搜索更多相关主题  帖子排序:
piaoling 发表于 2009/6/5 10:24:27
ASP VBSCRIPT 正则表达式之 替换 URL 与 EMAIL 地址为热链接zz

Regular Expression

1. 匹配 URL 并替换, www. 不超过四可正常工作, 或者说不超过三级域名, 本正则可正常工作
2. email 替换操作, 三级域名或以内, 本正则正常工作

---/---------------------------------------------------------

2. email 替换操作, 三级域名或以内, 本正则正常工作
'email 替换操作,  email 替换为 <a href=mailto:email>email</a>
Set re = New RegExp
re.Pattern = "([\w-]+\.+[\w-]+\@+)([\w-]+\.+[\w-]+\.+|[\w-]+\.+)([\w{1}][\w{2}][\w{3}]|[\w{1}][\w{2}])"
re.Global = true
re.IgnoreCase = true
result = re.Replace(result,"<a href=mailto:$1$2$3>$1$2$3</a>")
----------------------
'EMAIL 解码
Set re = New RegExp
re.Pattern = "(\<a href\=mailto\:)([\w-]+\.+[\w-]+\@+)([\w-]+\.+[\w-]+\.+|[\w-]+\.+)([\w{1}][\w{2}][\w{3}]|[\w{1}][\w{2}])(\>)(.*)(\<\/a\>)"
re.Global = true
re.IgnoreCase = true
Str = re.Replace(Str,"$6")

1. 匹配 URL 并替换, www. 不超过四可正常工作, 或者说不超过三级域名, 本正则可正常工作
'url 替换操作, www 替换为 <a href=http://www>www</a>
Set re = New RegExp
re.Pattern = "(http\:\/\/|^http\:\/\/)([\w-]+\.+[\w-]+\.+[\w-]+\.+[\w-]+|[\w-]+\.+[\w-]+\.+[\w-]+)(/[\w-./?%&=]*)?"
re.Global = true
re.IgnoreCase = true
result = re.Replace(result,"<a href=http://$2$3 target=_blank>$1$2$3</a>")
----------------------
'URL 解码
Set re = New RegExp
re.Pattern = "(\<a href\=\http\:\/\/)([\w-]+\.+[\w-]+\.+[\w-]+\.+[\w-]+|[\w-]+\.+[\w-]+\.+[\w-]+)(/[\w-./?%&=]*)?( target\=\_blank\>)(http\:\/\/|^http\:\/\/)([\w-]+\.+[\w-]+\.+[\w-]+\.+[\w-]+|[\w-]+\.+[\w-]+\.+[\w-]+)(/[\w-./?%&=]*)?(/[\w-./?%&=]*)(\<\/a\>)"
re.Global = true
re.IgnoreCase = true
Str = re.Replace(Str,"$5$6$7$8")

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

返回页首↑


津ICP备09000164号

联系我们 - piaoling Corporation - 论坛存档 - 返回顶端
Powered by BBSXP 2007 ACCESS © 1998-2025
Server Time 2025/1/15 6:20:40
Processed in 0.02 second(s)
飘凌大杂烩