62,074
社区成员
发帖
与我相关
我的任务
分享
string str = "<img src= image/ad1.gif width=\"128\" height=\"36\"/><img src='image/ad2.jpg' width=\"128\" height=\"36\" />"
+"<img src="
+"image/ad3.jpg' width=\"128\" height=\"36\" />";
Regex reg = new Regex(@"<img[^>]*?src=(['""\s]?)([^'""\s]+)\1[^>]*?>");
MatchCollection match = reg.Matches(str);
foreach (Match m in match)
{
Response.Write(m.Groups[2].Value + "<br/>");
}
/*
image/ad1.gif
image/ad2.jpg
image/ad3.jpg
*/
Regex reg = new Regex(@"(?i)<img\b[^>]*?src=(['""]?)([^'""\s>]+)\1[^>]*>");
MatchCollection mc = reg.Matches(yourStr);
foreach(Match m in mc)
{
richTextBox2.Text += m.Groups[2].Value + "\n"; //src
}