<span class="auxiInfo" style="float:right;padding:5px 0px 5px 5px;">2009-9-5 10:53:49</span>
<h2><a href="/sp/article/2009/200909/20090905/article_412879.htm">Li Na reaches fourth round at US Open</a></h2>
有以上文本,要求编写正则表达式可以从这个多行并且前面有空格的文本中取出以下三个结果:2009-9-5 10:53:49
="/sp/article/2009/200909/20090905/article_412879.htm
Li Na reaches fourth round at US Open
我写了一个,如果一行文本还可以,多行就不行
string regexStr1 = "<span class=\"auxiInfo\" style=\"float:right;padding:5px 0px 5px 5px;\">(?<tdate>.*?)</span>(?s)<h2><a href=\"(?<url>.*?)\">(?<title>.*?)</a></h2>";
Regex r1 = new Regex(regexStr1, RegexOptions.Singleline);
MatchCollection mc1 = r1.Matches(strHtml1);
<h2><a href="/sp/article/2009/200909/20090905/article_412879.htm">Li Na reaches fourth round at US Open</a></h2>
有以上文本,要求编写正则表达式可以从这个多行并且前面有空格的文本中取出以下三个结果:2009-9-5 10:53:49
="/sp/article/2009/200909/20090905/article_412879.htm
Li Na reaches fourth round at US Open
我写了一个,如果一行文本还可以,多行就不行
string regexStr1 = "<span class=\"auxiInfo\" style=\"float:right;padding:5px 0px 5px 5px;\">(?<tdate>.*?)</span>(?s)<h2><a href=\"(?<url>.*?)\">(?<title>.*?)</a></h2>";
Regex r1 = new Regex(regexStr1, RegexOptions.Singleline);
MatchCollection mc1 = r1.Matches(strHtml1);
MatchCollection mc = reg.Matches(yourStr);
foreach (Match m in mc)
{
richTextBox2.Text += m.Groups["tdate"].Value + "\n";
richTextBox2.Text += m.Groups["url"].Value + "\n";
richTextBox2.Text += m.Groups["title"].Value + "\n";
}