aaaa<e>aaaleerel</e>;lkjfsfjsfs<e>lsdjfla</e>lskdjfaldj 
RT
刚学一天正则
我自己写的(? <= <e>).*?(?= </e>) 报错

解决方案 »

  1.   


    (?<=<e>).*?(?=</e>)没问题..
      

  2.   

    <e>(.*?)</e>
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://feiyun0112.cnblogs.com/
      

  3.   

        class Program
        {
            static void Main()
            {
                string s;
                Regex r = new Regex(@"(? <= <e>).*?(?= </e>)");// 1
                MatchCollection mc = r.Matches("aaaa<e>aaaleerel</e>;lkjfsfjsfs<e>lsdjfla</e>lskdjfaldj ");
                foreach (Match m in mc)
                {
                    s=m.ToString();/这里确定有值就行
                }
            }
        }刚执行到1,就出错  正在分析“(? <= <e>).*?(?= </e>)”- 无法识别的分组构造。
      

  4.   


                string s; 
                Regex r = new Regex(@"(?<=<e>).*?(?=</e>)");// 1 
                MatchCollection mc = r.Matches("aaaa <e>aaaleerel </e>;lkjfsfjsfs <e>lsdjfla </e>lskdjfaldj "); 
                foreach (Match m in mc) 
                { 
                    s=m.ToString();
                    Console.WriteLine(s);
                } 
    可以的 你火星编译器
      

  5.   

    不会B 我是VS2008啊 而且我还有个 REGEX编译器 2个东西同时报错..
      

  6.   


    //你的正则 前瞻中 多了个空格 
    //把这(?  <=  <e>).*?(?=  </e>)
    //改为(?<=  <e>).*?(?=  </e>)
    //这个试试看Regex objRegex = new Regex(@"(?i)(?<=\<e\>)[^<]+(?=\<\/e\>)");