大家好,在线等待,php转C#代码,希望大家能指点!!!$re='/<li title=([^:]*):([^<]*)<\/li>/';
preg_match_all($re,$tempstr,$matches);
$itemstr=$matches[2][0];
for($i = 1; $i < count($matches[2]); $i++)
{
   $itemstr=$itemstr.",";
   $itemstr=$itemstr.$matches[2][$i];   
}
我想把这段改成c#
希望大家能指点一下吗

解决方案 »

  1.   

    using System.Text.RegularExpressions;
    ...
                    Regex re = new Regex(@"/ <li title=([^:]*):([^ <]*) <\/li>/", RegexOptions.Compiled);
                    MatchCollection mc = re.Matches(tempstr);
                    string itemstr = mc[2].Groups[0].ToString();
                    for (int i = 1; i < mc[2].Groups.Count; i++)
                    {
                        itemstr += "," + mc[2].Groups[i].ToString();
                    }