html求一难点的正则
<a href="http://nn.c365.com/newhouse/h234.shtml#teambuy"
target="_blank">我要团购</a>
<a
href=http://nn.c365.com/newhouse/h758.shtml#teambuy target="_blank">我要团购</a>
<a href='http://nn.c365.com/newhouse/h787.shtml#teambuy' target="_blank">我要团购</a>
<a target="_blank" href="h234.shtml#teambuy">我要团购</a>
<a target="_blank" href=http://nn.c365.com/newhouse/h34.shtml#teambuy>我要团购</a>
<a target="_blank" href='http://nn.c365.com/newhouse/h4.shtml#teambuy'>我要团购</a>
<p>
<strong><a href="http://nn.zp365.com/newhouse/h2.shtml" target="_blank">中房翡翠园</a></strong>【<a href="http://nn.zp365.com/newhouse/h2.shtml" target="_blank">详情</a> <a href="http://nn.zp365.com/newhouse/HouseImgList.aspx?hid=2&tid=0" target="_blank">户型</a> <a href="http://nn.zp365.com/newhouse/HouseImgGeneralList.aspx?hid=2" target="_blank">图库</a> <a href="http://nn.zp365.com/newhouse/otherInfo.aspx?hid=2&typeInfo=Dc" target="_blank">动态</a> <a href="http://nn.zp365.com/newhouse/HouseMap.aspx?hid=2" target="_blank">地图</a>】 <a href="http://nn.c365.com/newhouse/h2.shtml#teambuy">>>>我要团购</a></p>
含有#teambuy的连接,把 target="_blank"和连接href里的内容替换成 href="javascript:;" onclick="showTeamBuy('234')"
红色的数字保留
我写的是Response.Write(Regex.Replace(s, "<a([^<>]+)href=("|'|).*?(\\d+)\\.shtm([^<>]+)#teambuy("|'|)(([^<>]+)|)>", "<a href="javascript:;" onclick="showTeamBuy('$3')">"));
但里面的很多连接都替换了