<script language="VBScript">
<!--
Function RemoveHTML(strHTML)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
'取闭合的<>
objRegExp.Pattern = "<img src=.+?>"
Set Matches = objRegExp.Execute(strHTML)
For Each Match in Matches
t=t & Match.value
Next
RemoveHTML=t
Set objRegExp = Nothing
End Function
a="<br>这是一个IMG函数<img src=""http://www.baidu.com/img/logo-yy.gif"">这是结束位置"
msgbox replace(replace(replace(replace(replace(removehtml(a),"<",""),">",""),"img",""),"""",""),"src=","")
-->
</script>
<script type="text/javascript">
<!--
var imgurl1="<img src=\"sdf1.gif\" border=0 height=0>sdfds<img src=\"sdf2.gif\" border=0 height=0>sdds<img src=\"sdf3.gif\" border=0 height=0>";
var reimg=/<img src=(.+?)>/gi;
if(arr=imgurl1.match(reimg)){
for(i=0;i<arr.length;i++){
alert(arr[i].replace(/<img src=([^\s]+)\s*[^>]*>/gi,"$1"));
}
}
-->
</script>
<script language="VBScript">
a="<br>这是一个IMG函数<img width=130 οnclick=""test();"" src=""http://www.baidu.com/img/logo-yy.gif"">这是<img width=130 οnclick=""test();"" src=""http://www.baidu.com/img/logo-yy2.gif"">"
call process_content_photo(a)
'==============================
''处理内容中所有图片
'==============================
Function process_content_photo(strContent)
Dim objRegEx,MyPics, MyPic
Set objRegEx = New RegExp
objRegEx.IgnoreCase = true
objRegEx.Global = True
objRegEx.Pattern = "<img[^<>]+?>"
Set MyPics = objRegEx.Execute(strContent)
For Each MyPic in MyPics
document.write(GetAttribute("src", MyPic.Value) & "<br>")
Next
Set MyPics = Nothing
Set objRegEx = Nothing
End Function
'==============================
'【功能】取得参数值
'==============================
Function GetAttribute(ByVal strAttribute, ByVal strtag)
Dim objRegEx, Matches
'建立正则表达式
Set objRegEx = New RegExp
'查找内容
objRegEx.Pattern = LCase(strAttribute) & "=""([^\[]*)"""
'忽略大小写
objRegEx.IgnoreCase = True
'全局查找
objRegEx.Global = True
'执行搜索
Set Matches = objRegEx.Execute(strtag)
'如有匹配的则返回值, 不然返回空值
If Matches.Count > 0 Then
GetAttribute = Split(Matches(0).Value, """")(1)
Else
GetAttribute = ""
End If
'消毁对象
Set Matches = Nothing
Set objRegEx = Nothing
End Function
</script>
转载于:https://www.cnblogs.com/exit/archive/2010/11/10/1874239.html