62,269
社区成员
发帖
与我相关
我的任务
分享<div class="basic" style="float:left;" id="list1a">
<a>There is one obvious advantage:</a>
<div>
<p>
You've seen it coming!<br/>
Buy now and get nothing for free!<br/>
Well, at least no free beer. Perhaps a bear,<br/>
if you can afford it.
</p>
</div>
<a>Now that you've got...</a>
<div>
<p>
your bear, you have to admit it!<br/>
No, we aren't selling bears.
</p>
</div>
<a>Rent one bear, ...</a>
<div>
<p>
get two for three beer.
</p>
<p>
<a>And now, for something completely different.</a>
<a>And now, for something completely different.</a>
<a>And now, for something completely different.</a>
<a>And now, for something completely different.</a>
<a>And now, for something completely different.</a>
And now, for something completely different.<br/>
And now, for something completely different.<br/>
And now, for something completely different.<br/>
Period.
</p>
</div>
</div>
Match mStr = Regex.Match(str, @"<div[^>]*?id=""list1a""[^>]*>(((?<o>)<div[^>]*>|(?<-o>)</div>|(?:(?!</?div)[\s\S]))*)(?(o)(?!))</div>", RegexOptions.IgnoreCase);
if (mStr.Success)
{
MatchCollection mc = Regex.Matches(mStr.Value, @"<a[^>]*>([\s\S]*?)</a>\s*<div[^>]*>([\s\S]*?)</div>", RegexOptions.IgnoreCase);
foreach (Match m in mc)
{
richTextBox1.Text += m.Groups[1].Value + "\n";
richTextBox1.Text += m.Groups[2].Value + "\n";
richTextBox1.Text += "---------------------------\n";
}
}Match mStr = Regex.Match(str, @"<div[^>]*?id=""list1a""[^>]*>(((?<o>)<div[^>]*>|(?<-o>)</div>|(?:(?!</?div)[\s\S]))*)(?(o)(?!))</div>", RegexOptions.IgnoreCase);
if (mStr.Success)
{
MatchCollection mc = Regex.Matches(mStr.Value, @"(<a[^>]*>[\s\S]*?</a>)\s*(<div[^>]*>[\s\S]*?</div>)", RegexOptions.IgnoreCase);
foreach (Match m in mc)
{
richTextBox1.Text += m.Groups[1].Value + "\n";
richTextBox1.Text += m.Groups[2].Value + "\n";
richTextBox1.Text += "---------------------------\n";
}
}MatchCollection mc = Regex.Matches(str, @"(<a[^>]*>[\s\S]*?</a>)\s*(<div[^>]*>[\s\S]*?</div>)", RegexOptions.IgnoreCase);
foreach (Match m in mc)
{
richTextBox1.Text += m.Groups[1].Value + "\n";
richTextBox1.Text += m.Groups[2].Value + "\n";
richTextBox1.Text += "---------------------------\n";
}