大家好,我现在想从html源文件中提取新闻列表,格式主要匹配如下:
[国际新闻]</A><A                              href="javascript:wlwh('c_showwlwh.asp?wlwh_id=19200')">韩政府反对在中国大使馆前立“脱北者少女像”</A>中间有多条新闻,谢谢大家帮我一下,对正则不熟悉呀

解决方案 »

  1.   

    Try
    string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt
                    List<string> list = Regex.Matches(tempStr, @"(?i)<a[^>]*?href=(['""]?)[^""]*?:wlwh[^""]*?\1[^>]*?>([^<>]*?)</a>").Cast<Match>().Select(a=>a.Groups[2].Value).ToList();
                    // [0] "韩政府反对在中国大使馆前立“脱北者少女像”" string