当前位置: 代码迷 >> ASP.NET >> 求1图片属性名称替换的正则表达式
  详细解决方案

求1图片属性名称替换的正则表达式

热度:6117   发布时间:2013-02-25 00:00:00.0
求一图片属性名称替换的正则表达式
有一字符串
<img alt=\"凯乐石/皮肤风衣/深桔/KG112482\" src=\"/fckUpload/image/products/2012-07/201207210250452JR0_1.jpg\" /><img alt=\"凯乐石/皮肤风衣/深桔/KG112482\" src=\"/fckUpload/image/products/2012-07/201207210250508H6T_2.jpg\" />

想替换成
<img alt=\"凯乐石/皮肤风衣/深桔/KG112482\" original=\"/fckUpload/image/products/2012-07/201207210250452JR0_1.jpg\" src='/load.gif' /><img alt=\"凯乐石/皮肤风衣/深桔/KG112482\" original=\"/fckUpload/image/products/2012-07/201207210250508H6T_2.jpg\" src='load.gif' />

就是将原来图片的scr替换成original,另外再一个src='load.gif'

请问一下C#这个要怎么写呢;


------解决方案--------------------------------------------------------
C# code
string html="<img alt=\"凯乐石/皮肤风衣/深桔/KG112482\" src=\"/fckUpload/image/products/2012-07/201207210250452JR0_1.jpg\" /><img alt=\"凯乐石/皮肤风衣/深桔/KG112482\" src=\"/fckUpload/image/products/2012-07/201207210250508H6T_2.jpg\" />";html=Regex.Replace(html,@"(?i)(?<=<img\b[^>]*?)(src=)(.*?)(?=/>)",@"original=$2 src='/load.gif'");