解决方案 »

  1.   

     MatchCollection m = Regex.Matches("bolo cacd jeep", @"(\w)(?=.*?\1)");
                foreach (Match s in m)
                {
                    textBox1.Text += s.Value;
                }
      

  2.   


    string text = "book   deep   studio happy microsoft";
    var values = text.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).Where(a => a => a.Length - a.Distinct().Count()==1).ToArray();
    //output: 
    //values[0]=book 
    //values[1]=deep 
    //values[2]=happy
    //values[3]=microsoft
      

  3.   


    有重复 a => a.Length != a.Distinct().Count()
      

  4.   

      MatchCollection mc = Regex.Matches("book not jeep", @"\b\S*(\w)(\1)\S*\b");
                foreach (Match m in mc)
                {
                    Console.WriteLine(m.Value);
                }
      

  5.   

                Regex reg = new Regex(@"\w*(\w)\w*(\1)\w*");
                MatchCollection mc = reg.Matches(@"aba abccd sosis edfg");
                foreach (Match m in mc)
                {
                    Console.WriteLine(m.Value);
                }
    这个能把两个及两个以上重复的单词都匹配出来
      

  6.   

     string pattern = @"(?i)[a-z]*?([a-z])[a-z]*?\1[a-z]*";
      

  7.   

    之前那个是必须是挨着的两个字母,不一定挨着,是这样:
      MatchCollection mc = Regex.Matches("book noto jeeep", @"\b\S*(\w)\S*(\1)\S*\b");
                foreach (Match m in mc)
                {
                    Console.WriteLine(m.Value);
                }
      

  8.   


    分析了下,还是又地方不太懂,
    1、其中的a是什么东西呀,也没有定义;
    2、=>这个符号代表什么意思呢?
      

  9.   


    分析了下,还是又地方不太懂,
    1、其中的a是什么东西呀,也没有定义;
    2、=>这个符号代表什么意思呢?这个问题,你百度  lamda表达式 就知道了
      

  10.   

    之前那个是必须是挨着的两个字母,不一定挨着,是这样:
      MatchCollection mc = Regex.Matches("book noto jeeep", @"\b\S*(\w)\S*(\1)\S*\b");
                foreach (Match m in mc)
                {
                    Console.WriteLine(m.Value);
                }
    不好意思,您的两个答案都是正确的,而且都满足要求哦,是我自己弄错了,非常感谢您的细心答复哦~
      

  11.   


    分析了下,还是又地方不太懂,
    1、其中的a是什么东西呀,也没有定义;
    2、=>这个符号代表什么意思呢?这个问题,你百度  lamda表达式 就知道了搜噶!!明白啦~~多谢!!
    其实肯定学过,就是忘了,看来这个东西还得多练!