[英]c# Regex.Match problem
我在匹配文本以從HTML頁面提取數據時遇到一些問題。 這是我到目前為止的內容,但是plainText
保持空白:
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],或簡稱Match.Value。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.