C# 正则表达式匹配问题

C# 正则表达式匹配问题,c#,.net,regex,C#,.net,Regex,我在匹配文本以从HTML页面提取数据时遇到一些问题。以下是我到目前为止所拥有的内容,但纯文本保持为空: private void Scrape() { // create variables string html; string plainText; // download page source // sample URL: http://freekeywords.wordtracker.com/?seed=test&adult_filter=remove_of

我在匹配文本以从HTML页面提取数据时遇到一些问题。以下是我到目前为止所拥有的内容,但
纯文本
保持为空:

private void Scrape()
{
  // create variables
  string html;
  string plainText;

  // download page source
  // sample URL: http://freekeywords.wordtracker.com/?seed=test&adult_filter=remove_offensive&suggest=Hit+Me";
  html = webBrowser1.Document.Body.InnerText; 

  // scrape keywords
  plainText = Regex.Match(html, @"class='k'[^x]display: none""", RegexOptions.IgnoreCase).Groups[1].Value;

  //plainText = Regex.Replace(plainText, @"\,", Environment.NewLine);
  //plainText = Regex.Replace(plainText, @"""", "");

  this.richTextBox1.Text = html;
}

您试图从索引为1的组中获取值,但您的正则表达式不包含任何组。用户组[0],或者简单地匹配.Value。

使用正则表达式而不是使用HTML解析器解析HTML有什么好的理由吗?顺便说一下,我怀疑您的HTML是否真的包含类似于“k[not x]display:none”的代码片段