111,094
社区成员




<div class="pic"><a href="http://www.mbaobao.com/pshow-10223010.html" target="_blank"><img src="http://images.mbaobao.com/fansface/10223010/s.gif" width="160" height="160" alt="[FansFace]运动休闲两用旅行包 黑色" /></a></div>
<div class="text">
<div class="title"><a href="http://www.mbaobao.com/pshow-10223010.html" target="_blank" title="[FansFace]运动休闲两用旅行包 黑色">[FansFace]运动休闲两用旅行包 黑色</a></div>
市场价:<s>398.00</s><br />
麦包价:<span class="price">159.00</span><br />
span class="buy">
<a class="hand" onclick="add_goods_to_cart(3897);" rel="nofollow"><img src="http://www.mbaobao.com/templates/default/images/btn_cart.gif" width="87" height="22" alt="加入购物车" /></a>
<a class="hand" onclick="add_goods_to_favorites(3897);" rel="nofollow"><img src="http://www.mbaobao.com/templates/default/images/btn_favor.gif" width="50" height="22" alt="收藏" /></a>
</span>
</div>
string test = @"<div class=""pic""><a href=""http://www.mbaobao.com/pshow-10223010.html"" target=""_blank""><img src=""http://images.mbaobao.com/fansface/10223010/s.gif"" width=""160"" height=""160"" alt=""[FansFace]运动休闲两用旅行包 黑色"" /></a></div>
<div class=""text"">
<div class=""title""><a href=""http://www.mbaobao.com/pshow-10223010.html"" target=""_blank"" title=""[FansFace]运动休闲两用旅行包 黑色"">[FansFace]运动休闲两用旅行包 黑色</a></div>
市场价:<s>398.00</s><br />
麦包价:<span class=""price"">159.00</span><br />
span class=""buy"">
<a class=""hand"" onclick=""add_goods_to_cart(3897);"" rel=""nofollow""><img src=""http://www.mbaobao.com/templates/default/images/btn_cart.gif"" width=""87"" height=""22"" alt=""加入购物车"" /></a>
<a class=""hand"" onclick=""add_goods_to_favorites(3897);"" rel=""nofollow""><img src=""http://www.mbaobao.com/templates/default/images/btn_favor.gif"" width=""50"" height=""22"" alt=""收藏"" /></a>
</span>
</div>";
Regex reg = new Regex(@"(?is)<div class=""pic""><a href=""(?<url>[^""]*)""[^>]*><img src=""(?<img>[^""]*)""[^>]*>(?:(?!市场价:).)*市场价:<s>(?<p>[\d.]+)(?:(?!麦包价:).)*麦包价:<span[^>]*>(?<mp>[\d.]+)</span>");
MatchCollection mc = reg.Matches(test);
foreach (Match m in mc)
{
richTextBox2.Text += m.Groups["url"].Value + "\n";
richTextBox2.Text += m.Groups["img"].Value + "\n";
richTextBox2.Text += m.Groups["p"].Value + "\n";
richTextBox2.Text += m.Groups["mp"].Value + "\n";
}
/*-----------输出-------------
http://www.mbaobao.com/pshow-10223010.html
http://images.mbaobao.com/fansface/10223010/s.gif
398.00
159.00
*/
Regex reg = new Regex(@"(?is)<div class=""pic""><a href=""(?<url>[^""]*)""[^>]*><img src=""(?<img>[^""]*)""[^>]*>(?:(?!市场价:).)*市场价:<s>(?<p>[\d.]+)(?:(?!麦包价:).)*麦包价:<span[^>]*>(?<mp>[\d.]+)</span>");
MatchCollection mc = reg.Matches(yourStr);
foreach(Match m in mc)
{
richTextBox2.Text += m.Groups["url"].Value + "\n";
richTextBox2.Text += m.Groups["img"].Value + "\n";
richTextBox2.Text += m.Groups["p"].Value + "\n";
richTextBox2.Text += m.Groups["mp"].Value + "\n";
}
string s="你的字符串信息。。";
string sPatternLink = "(? <=href=\")[^\"]+ ";
string sLink=Regex.Match(s,sPatternLink ,RegexOptions.IgnoreCase).ToString();