日期:2014-05-17 浏览次数:20946 次
string zifuchuan = @"xxxxxxxx随机内容<a href=""read-htm-tid-8012348.html"" id=""a_ajax_8012348"">一只绣眼文章标题</a></span></h3> <span class='gray tpage'>( +9352 )</span> <img src=""images/wind/file/new.gif"" align=""absmiddle"" /> <span class=""tpage"">....中间很多无用数据.......d-8012348-page-11-fpage-1.html"">11</a></span> </span> </td> <td class=""tal y-style""><a href=""u-htm-action-show-uid-278024.html"" class=""bl"">老海人名</a> <div class=""f10 gray2"">2012-10-12</div></td> <td class=""tal y-style f10""><span class=""s8"">107</span> / 795</td>随机内容xxxxxxxx"; foreach (Match m in Regex.Matches(zifuchuan, @"(?is)<a href=""read-htm-tid-\d+\.html""[^>]*>(.*?)</a>.+?<a href=""u-htm-action-show-uid-\d+\.html"" class=""bl"">(.*?)</a>\s*<div class=""f10 gray2"">(.*?)</div>.*?<span class=""s8"">(\d+)</span>\s*/\s*(\d+)</td>")) { Response.Write(m.Groups[1].Value + "<br/>"); Response.Write(m.Groups[2].Value + "<br/>"); Response.Write(m.Groups[3].Value + "<br/>"); Response.Write(m.Groups[4].Value + "<br/>"); Response.Write(m.Groups[5].Value + "<br/>"); }
------解决方案--------------------
string html = @"xxxxxxxx随机内容<a href=""read-htm-tid-8012348.html"" id=""a_ajax_8012348"">一只绣眼文章标题</a></span></h3> <span class='gray tpage'>( +9352 )</span> <img src=""images/wind/file/new.gif"" align=""absmiddle"" /> <span class=""tpage"">....中间很多无用数据.......d-8012348-page-11-fpage-1.html"">11</a></span> </span> </td> <td class=""tal y-style""><a href=""u-htm-action-show-uid-278024.html"" class=""bl"">老海