c#正则表达式这个怎么写
c#正则表达式这个怎么写
<span class="ww-light ww-large" data-nick="qiangkuan0813" data-display="inline"><a href="http://www.taobao.com/webww/?spm=a1z09.3.3.1.d81b95&ver=1&&touid=cntaobaoqiangkuan0813&siteid=cntaobao&status=2&portalId=&gid=&itemsId=" target="_blank" class="ww-inline ww-online" title="点此可以直接和卖家交流选好的宝贝,或相互交流网购体验,还支持语音视频噢。" data-spm-anchor-id="a1z09.3.3.1"><span>旺旺在线</span></a></span>
<span class="ww-light ww-large" data-nick="树袋熊趴趴" data-display="inline"><a href="http://www.taobao.com/webww/?spm=a1z09.3.3.1.6befa1&ver=1&touid=cntaobao%E6%A0%91%E8%A2%8B%E7%86%8A%E8%B6%B4%E8%B6%B4&siteid=cntaobao&status=1&portalId=&gid=&itemsId=" target="_blank" class="ww-inline ww-offline" data-spm-anchor-id="a1z09.3.3.1"><span>旺旺离线</span></a></span>
如何获取红色网址
------解决方案--------------------
(?is)<span\s*[^>]*?>\s*<a\s*href=(["']?)(?<href>[^"']*?)\1[^>]*?>
取Groups["href"].Value
------解决方案--------------------
C# code
string str = File.ReadAllText(@"E:\download\网站测试.txt", Encoding.Default);
Regex reg = new Regex(@"<span class=""ww-light ww-large""[^>]+?><a href=""([^""]+?)""[^>]+?>");
foreach (Match m in reg.Matches(str))
{
Response.Write(m.Groups[1].Value+"<br/>");
}