我的正则表达式使用中是否有任何错误?

时间:2015-09-12 12:52:03

标签: c# regex

我正在尝试从此page获取以下字符串。

./khan_index.html?artid=(numbers)&code=361102

所以我用这个正则表达式得到它。

\.\/khan_index\.html\?artid=\d+&code=361102

代码如下;

        using (WebClient client = new WebClient())
        {
            htmlCode = client.DownloadString("http://news.khan.co.kr/kh_cartoon/khan_index.html?mode=list&code=361102&page=1");
        }

        string pattern = (@"\.\/khan_index\.html\?artid=\d+&code=361102");
        MatchCollection matches = Regex.Matches(htmlCode, pattern);

我运行了代码,但matches的计数仍为0.

有什么问题?

1 个答案:

答案 0 :(得分:0)

我认为问题是&你能否展示htmlCode变量的内容,或者只是替换\.\/khan_index\.html\?artid=\d+&code=361102中的\.\/khan_index\.html\?artid=\d+&code=361102