日期:2014-05-18  浏览次数:20995 次

C# 把正则匹配数据输入到数组中。。急
string bar_codes="471444332∩100332334744,100337989550,100437827263,|471240031∩100332334744,100337989550,100437827263,|";
  List<string> pro = new List<string>();
  Match match = Regex.Match(bar_codes, @"4\d+\∩", RegexOptions.IgnoreCase);
  pro=match.Groups;//这里错误

二个问题,1,正则怎么改,才能匹配到∩之前,现在的结果是
共找到 2 处匹配:
471444332∩
471240031∩

2,最后不是获取匹配的集合吗,为什么不对???高人指点,我想把匹配的数据输入到list数组中。。。

------解决方案--------------------
C# code

            List<string> strE_ = new List<string>();//新定义个List
            var sel = from t in pro group t by t into g where g.Count() > 1 select g.Distinct();// select g;
            foreach (var sel1 in sel)
            {
                foreach (string msel in sel1)
                {
                    strE_.Add(msel);
                }
            }