正则表达式只返回一次结果

xlcc 2009-04-05 01:10:09
Function getImages(Str)
Set re = New RegExp
re.Pattern = "<img(.+?)src=""*([^\s]+?)""*(\s|>)"
re.Global = True
re.IgnoreCase = True
Set Contents = re.Execute(Str)
For Each Match in Contents ' 遍历匹配集合。
Images = Images + Match.SubMatches(1) + "|"
Next
getImages = Mid(Images, 1, Len(Images) -1)
End Function

文章中有多个JPG,如果只选择第一个JPG?
...全文
109 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
森少 2009-06-17
  • 打赏
  • 举报
回复
……
lonelyriver 2009-04-07
  • 打赏
  • 举报
回复
……
xlcc 2009-04-05
  • 打赏
  • 举报
回复
Function getImages(Str)
Set re = New RegExp
re.Pattern = "<img(.+?)src=""*([^\s]+?)""*(\s|>)"
re.Global = True
re.IgnoreCase = True
Set Contents = re.Execute(Str)
Images = Contents(0).SubMatches(1)
getImages = Mid(Images, 1, Len(Images) -0)
End Function

自己搞定

1,451

社区成员

发帖
与我相关
我的任务
社区描述
多媒体/设计/Flash/Silverlight 开发 图象工具使用
社区管理员
  • 图象工具使用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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