日期:2014-05-17  浏览次数:20540 次

求一图片属性名称替换的正则表达式
有一字符串
<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'");