1 <div class="activity_banner"> 2 <img src="http://act.shangpin.com/brand/Activities/201402270310bluegirl/images/img01.jpg" width="1900" height="540" border="0" /> 3 </div> 4 <div class="activity_wp_cn"> 5 <img src="http://act.shangpin.com/brand/Activities/201402270310bluegirl/images/img02.jpg" width="960" height="400" border="0" /> 6 <img src="http://act.shangpin.com/brand/Activities/201402270310bluegirl/images/img03.jpg" width="960" height="400" border="0" /> 7 <img src="http://act.shangpin.com/brand/Activities/201402270310bluegirl/images/img04.jpg" width="960" height="400" border="0" /> 8 </div>
我想变成
1 <div class="activity_banner"> 2 <img src="/aolai/images/e.gif" lazy="http://act.shangpin.com/brand/Activities/201402270310bluegirl/images/img01.jpg" width="1900" height="540" border="0" /> 3 </div> 4 <div class="activity_wp_cn"> 5 <img src="/aolai/images/e.gif" lazy="http://act.shangpin.com/brand/Activities/201402270310bluegirl/images/img02.jpg" width="960" height="400" border="0" /> 6 <img src="/aolai/images/e.gif" lazy="http://act.shangpin.com/brand/Activities/201402270310bluegirl/images/img03.jpg" width="960" height="400" border="0" /> 7 <img src="/aolai/images/e.gif" lazy="http://act.shangpin.com/brand/Activities/201402270310bluegirl/images/img04.jpg" width="960" height="400" border="0" /> 8 </div>
用正则怎么写呀?多谢各位帮忙啊~~!
这个不难
经测试通过:
static void Main(string[] args) { Regex r = new Regex("http:.*?\""); string source ="<img src=\"http://act.shangpin.com/brand/Activities/201402270310bluegirl/images/img01.jpg\" width=\"1900\" height=\"540\" border=\"0\" />"; string dest = r.Replace(source, new MatchEvaluator(x =>"/aolai/images/e.gif\" lazy=\""+ x.ToString())); Console.Read(); }