asp.net 正则表达式 获取图片
不同浏览器下 fck编辑器img 中 属性显示顺序不同
ie8 <img title="" alt="0" width="212" height="19" score="0" src="../../ImportWord/images/timuType1.gif" />
ie6 <img title="" height="19" alt="0" width="36" score="0" src="../../ImportWord/images/timuType1.gif" />
求asp.net 正则表达式 我想不管用户使用什么浏览器 都可以获取含有timuType 文字的图片 并获取其各个属性的值
条件:
<img title="" height="19" alt="0" width="36" score="0" src="../../ImportWord/images/timuType1.gif" />
<img title="" alt="0" width="212" height="19" score="0" src="../../ImportWord/images/timuType2.gif" />
<img src="abc.gif"/>
<img title="" alt="0" width="212" height="19" score="0" src="../../ImportWord/images/timuType2.gif" />
<img src="abc.gif"/>
结果:
<img title="" height="19" alt="0" width="36" score="0" src="../../ImportWord/images/timuType1.gif" />
<img title="" alt="0" width="212" height="19" score="0" src="../../ImportWord/images/timuType2.gif" />
<img title="" alt="0" width="212" height="19" score="0" src="../../ImportWord/images/timuType2.gif" />
最后还有获取出以上图片的各个属性
------解决方案--------------------再改下正则:
(?=<img[^>]* src="[^"]*timuType\d+\.gif"[^>]*>)<img(?:\s+title="(?<title>[^"]*)"
------解决方案--------------------\s+height="(?<height>[^"]*)"
------解决方案--------------------\s+alt="(?<alt>[^"]*)"
------解决方案--------------------\s+width="(?<width>[^"]*)"
------解决方案--------------------\s+score="(?<score>[^"]*)"
------解决方案--------------------\s+src="(?<src>[^"]*)")+[ /]*>