0
我想要做的是從下面的stringXML獲取IMG SRC URL。 (即http://www.webserver.com/picture.jpg)vbscript正則表達式獲取img src網址
這是我有什麼,但它僅給我的true/false:
<%
stringXML="<a href="http://www.webserver.com/"><img src="http://www.webserver.com/picture.jpg"/></a><br>Some text here, blah blah blah."
Dim objRegex
Set objRegex = New Regexp
With objRegEx
.IgnoreCase = True
.Global = True
.Multiline = True
End with
strRegexPattern = "\<img\s[^\>]*?src=[""'][^\>]*?(jpg|bmp|gif)[""']"
objRegEx.Pattern = strRegexPattern
response.write objRegEx.Test(stringXML)
If objRegEx.Test(stringXML) = True Then
'The string has a tags.
'Match all A Tags
Set objRegExMatch = objRegEx.Execute(stringXML)
If objRegExMatch.Count > 0 Then
Redim arrAnchor(objRegExMatch.Count - 1)
For Each objRegExMatchItem In objRegExMatch
response.write objRegExMatchItem.Value
Next
End If
End If
%>
我基本上只想得到IMG SRC值..
任何想法,爲什麼這行不工作'response.write objRegExMatchItem.Value'?
乾杯, 德魯
謝謝SOOOO多!這只是解決了谷歌搜索和試用/錯誤的幾個小時。再次感謝!!! – Drew
一個問題是,這也適用於CSS和腳本標籤,現在試圖解決這個問題... –