日期:2014-05-18 浏览次数:20684 次
string yourStr = .......; MatchCollection mc = Regex.Matches(yourStr, @"<img[^>]*?src=(['""]?)(?<img>[^'""\s>]*)\1[^>]*>", RegexOptions.IgnoreCase); foreach (Match m in mc) { richTextBox2.Text += m.Groups["img"].Value + "\n"; }
------解决方案--------------------
<html> <script> function getImage() { var imgs = document.getElementsByTagName('img'); var msg=''; for(var i = 0 ; i < imgs.length ; i++) { msg += imgs[i].src + '\n'; } alert(msg); } </script> <body> <img src="aaaa1.jpg"></img> <div> <img src="aaaa2.jpg"></img> <div> <img src="aaaa3.jpg"></img> </div> </div> <button onclick="getImage()">获取</button> </body> </html>
------解决方案--------------------
js就行了
<html>
<head>
<script>
function getImgUrl()
{
var elm = document.getElementsByTagName("img");
var len = document.getElementsByTagName("img").length;
for(var i=0; i<len;i++)
{
alert(elm[i].src)
}
}
</script>
</head>
<body>
<input type="button" onclick="getImgUrl()" value="click me">
<img src="http://community.csdn.net/ui/scripts/Csdn/_resources/FrameMDI/forum.gif">
<img src="http://profile.csdn.net/my/3.jpg">
<img src="http://community.csdn.net/ui/scripts/Csdn/_resources/FrameMDI/message.gif">
<img src="http://community.csdn.net/ui/scripts/Csdn/_resources/FrameMDI/prj.gif">
<img src="http://zi.csdn.net/300x60_15k.gif">
</body>
</html>