<IMG alt="" src=" http://localhost:31453/sehr.web/system_dntb/upload/粉刷梦想1280x800_001.jpg" width=1280 height=800>11111<IMG alt="" src=" http://localhost:31453/sehr.web/system_dntb/upload/粉刷梦想1280x800_001.jpg" width=1280 height=800>我想得到所有的#]<IMG alt="" src=" http://localhost:31453/sehr.web/system_dntb/upload/粉刷梦想1280x800_001.jpg" width=1280 height=800>这个的<IMG>节点
正则应该怎么写呢
正则应该怎么写呢
解决方案 »
- 根据关键字显示商品
- asp.net中Master模版页和相对路径的问题(菜鸟帖不喜勿喷)
- “DropDoLisex”有一个无效 SelectedValue,因为它不在项目列表中。
- 做web开发的页面有专门用户界面设计人员,而后台处理又有专门的程序人员,这个界面设计好之后与后台程序是怎样配合的呢???
- asp.net[自定义控件无法触发Repeater的ItemCommand事件]
- ASP.NET 怎么生成DLL文件?
- 请教ASP.NET连接数据库问题。在线等待!
- @购物车不能用
- 水晶报表结合IE打印完整解决方案!!!!!!
- 请问一个页面上的ascx能互相引用各自的对象吗?
- 关于将AD账号添加到域的问题
- JS如何传递一个对象
void Main()
{
string html=@"<IMG alt="""" src="" http://localhost:31453/sehr.web/system_dntb/upload/粉刷梦想1280x800_001.jpg"" width=1280 height=800>11111<IMG alt="""" src="" http://localhost:31453/sehr.web/system_dntb/upload/粉刷梦想1280x800_001.jpg"" width=1280 height=800>"; foreach(Match m in Regex.Matches(html,@"(?is)<img[^>]*>"))
{
Console.WriteLine(m.Value);
}
}/*
<IMG alt="" src=" http://localhost:31453/sehr.web/system_dntb/upload/粉刷梦想1280x800_001.jpg" width=1280 height=800>
<IMG alt="" src=" http://localhost:31453/sehr.web/system_dntb/upload/粉刷梦想1280x800_001.jpg" width=1280 height=800>
*/
(?is)<img\b[^>]*>
否则纯文本中:
"<img标签表示图片,需要/>结尾"
也被匹配了
void Main()
{
string html=@"<IMG alt="""" src="" http://localhost:31453/sehr.web/system_dntb/upload/粉刷梦想1280x800_001.jpg"" width=1280 height=800>11111<IMG alt="""" src="" http://localhost:31453/sehr.web/system_dntb/upload/粉刷梦想1280x800_001.jpg"" width=1280 height=800>"; foreach(Match m in Regex.Matches(html,@"(?is)<img[^>]*src=(['""]?)(?<src>[^'""]+)\1[^>]*width=(?<width>\d+)[^>]*height=(?<height>\d+)[^>]*>"))
{
Console.WriteLine("src= "+m.Groups["src"].Value);
Console.WriteLine("width= "+m.Groups["width"].Value);
Console.WriteLine("height= "+m.Groups["height"].Value);
}
}/*
src= http://localhost:31453/sehr.web/system_dntb/upload/粉刷梦想1280x800_001.jpg
width= 1280
height= 800
src= http://localhost:31453/sehr.web/system_dntb/upload/粉刷梦想1280x800_001.jpg
width= 1280
height= 800
*/