+ -
当前位置:首页 → 问答吧 → vbs正则匹配src的问题?

vbs正则匹配src的问题?

时间:2011-08-06

来源:互联网

VBScript code

str="<img src=""a.jpg""><img src=""b.jpg"">"
Dim regEx,Match,Matches        '建立变量。 
Set regEx=New RegExp           '建立正则表达式。 
regEx.Pattern="<img src=[\ '\ "]?([^\ <\ '\ "]*)[\ '\ "]?>"         '设置模式。 
regEx.IgnoreCase=True       '设置是否区分字符大小写。 
regEx.Global=True           '设置全局可用性。 
'alert tempvalue   
Set Matches=regEx.Execute(str) 
For Each Match In Matches         '遍历匹配集合。 
    RetStr=RetStr&Match.Value
Next 
if RetStr<>"" then 
  response.write(RetStr)
end if
'我想利用正则,读取src的值,可什么也没读出来,请大家帮看看?

作者: quweiie   发布时间: 2011-08-06

please help me

作者: quweiie   发布时间: 2011-08-06

<script type="text/vbscript">
<!--
str="<img src=""a.jpg""><img src=""b.jpg"">"
Dim regEx,Match,Matches '建立变量。 
Set regEx=New RegExp '建立正则表达式。 
regEx.Pattern="<img src=(['""]?)([^ '""]*)\1[^>]?>" '设置模式。 
regEx.IgnoreCase=True '设置是否区分字符大小写。 
regEx.Global=True '设置全局可用性。 
'alert tempvalue  
Set Matches=regEx.Execute(str) 
For Each Match In Matches '遍历匹配集合。 
  RetStr=RetStr&Match.submatches(1)
Next 
if RetStr<>"" then 
  msgbox(RetStr)
end if
//-->
</script>

作者: hongmei85   发布时间: 2011-08-06