求个正则表达式 提取超连接的

lang11zi 2007-12-11 01:05:41
<a target="_blank" href="../../play.asp?id=2006&m=2&n=1&u=1&v=1">[第01集]</a>
<a target="_blank" href="../../play.asp?id=2006&m=2&n=2&u=1&v=1">[第02集]</a>

怎么把../../play.asp?id=2006&m=2&n=1&u=1&v=1和../../play.asp?id=2006&m=2&n=2&u=1&v=1
提取出来 其他都不要


Function RegExpTest(patrn,strng)
Dim re,Match,Matches
RetStr=strng
Set re = New RegExp
re.Pattern = patrn
re.IgnoreCase = True
re.Global = True
Set Matches = re.Execute(strng)
For Each Match in Matches
RetStr=RetStr+match.value
Next
RegExpTest = RetStr
End Function

Html3="<a target=""_blank"" href=""../../play.asp?id=2006&m=2&n=1&u=1&v=1"">[第01集]</a>
<a target=""_blank"" href=""../../play.asp?id=2006&m=2&n=2&u=1&v=1"">[第02集]</a>"
pattern="<a\s(.*?)+href=(\"")?(.+?)(\"")?\s*(.*?)>(.+?)</a>"
Stest=RegExpTest(pattern,Html3)
response.write Stest
这个好象不行
...全文
103 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
cloudgamer 2007-12-11
  • 打赏
  • 举报
回复


Function getText(fString, patrn,n)
dim Matches, tStr
tStr = fString
Set re = New Regexp
re.IgnoreCase = True
re.Global = True
re.Pattern = patrn
set Matches = re.Execute(tStr)
set re = nothing
rStr = ""
For Each Match in Matches
rStr = Match.SubMatches(n)
exit for
Next
getText = rStr
End Function

dim Matches
sub setMatches(str,sRe)
Set re = New Regexp
re.IgnoreCase = True
re.Global = True
re.Pattern = sRe
set Matches = re.Execute(str)
set re=nothing
end sub

Html3=" <a target=""_blank"" href=""../../play.asp?id=2006&m=2&n=1&u=1&v=1""> [第01集] </a> <a target=""_blank"" href=""../../play.asp?id=2006&m=2&n=2&u=1&v=1""> [第02集] </a> "

pattern="<a[^>]*?>"

call setMatches(Html3,pattern)
For Each Match in Matches
response.write getText(Match.value, "href=""([^""]*?)""", 0) + "<br>"
Next
hztgcl1986 2007-12-11
  • 打赏
  • 举报
回复

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧