求助大侠一段源代码中,很多类似
<a href="read-htm-tid-4546.html" id="a_ajax_4546">今后转移工作重点</a>
<a href="read-htm-tid-7969541.html" id="a_ajax_7969541">检讨书一份</a>
这样的。我需要提取 一个帖子号码 和 一个标题,如下:
4546 和 今后转移工作重点
7969541 和 检讨书一份要求每个数组里存帖子号码,和标题,中间用逗号分开,求正则表达式!我用的如下代码
MatchCollection mc = Regex.Matches(strHtmlBody, 这里怎么写);
string[] result = new string[mc.Count];
for (int i = 0; i < mc.Count; i++)
{
result[i] = mc[i].Value;
}
<a href="read-htm-tid-4546.html" id="a_ajax_4546">今后转移工作重点</a>
<a href="read-htm-tid-7969541.html" id="a_ajax_7969541">检讨书一份</a>
这样的。我需要提取 一个帖子号码 和 一个标题,如下:
4546 和 今后转移工作重点
7969541 和 检讨书一份要求每个数组里存帖子号码,和标题,中间用逗号分开,求正则表达式!我用的如下代码
MatchCollection mc = Regex.Matches(strHtmlBody, 这里怎么写);
string[] result = new string[mc.Count];
for (int i = 0; i < mc.Count; i++)
{
result[i] = mc[i].Value;
}
id 7969541 text 检讨书一份
Press any key to continue . . .
string[] result = new string[mc.Count];
for (int i = 0; i < mc.Count; i++)
{
result[i] = mc[i].Groups["number"].Value + "," + mc[i].Groups["title"].Value;
}
//测试代码
foreach (string s in result)
{
richTextBox2.Text += s + "\n";
}
/*-----输出-----
4546,今后转移工作重点
7969541,检讨书一份
*/