得到一html 字符串 其他的标签省略,关键的地方是:
<li><a href="/ArcGIS/rest/services/CSP_Imagery_World_2D/MapServer">中国</a> (MapServer)</li>
<li><a href="/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer">美国</a> (MapServer)</li>
<li><a href="/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer">日本</a> (MapServer)</li>
如何从中 提取出 中国  美国   日本  这三个字符串呢??谢谢

解决方案 »

  1.   

    xml可以么?
    不行就直接用'<'和'>'做拆分
    str.split('<')[2].split('>')[1]
    应该就可以了
      

  2.   

    http://blog.csdn.net/allonkwok/archive/2009/10/30/4748296.aspx
      

  3.   

                string input = "<li><a href=\"/ArcGIS/rest/services/CSP_Imagery_World_2D/MapServer\">中国</a> (MapServer)</li>";
                string pattern = @"(?<=<[a].*>)(.*)(?=</a>)"; MatchCollection matches = Regex.Matches(input, pattern);
                foreach (Match match in matches)
                {
                  
                    Console.WriteLine(match.Groups[1].Value);
                                    
                }
      

  4.   

      string input ="<li><a href=\"/ArcGIS/rest/services/CSP_Imagery_World_2D/MapServer\">中国</a> (MapServer)</li> "+
                              "<li><a href=\"/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer\">美国</a> (MapServer)</li>"+
                              "<li><a href=\"/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer\">日本</a> (MapServer)</li>";            string pattern = "(?<=MapServer\">)(.*?)(?=</a>)"; MatchCollection matches = Regex.Matches(input, pattern);
                foreach (Match match in matches)
                { 
                    Console.WriteLine( match.Groups[1].Value);