找不含“<%/* */%>”的字符串例如有两个字符串匹配
“AAAA<%/*CCCCC*/%>BBBBB”“tafasfasdfasdfasdf”最后找到的是
“tafasfasdfasdfasdf”
这个   *([^(<%/*)])*([^(*/%>)])*   正则表达式不成应怎么改

解决方案 »

  1.   

    原贴我的理解错误,不能全拿你的分 string s1 = "AAAA<%/*CCCCC*/%>BBBBB";
            string s2 = "tafasfasdfasdfasdf";
            string sP = "<\\%\\/\\*.*?(\\*\\/%>)";
            Response.Write(System.Text.RegularExpressions.Regex.IsMatch(s1, sP));
            Response.Write(System.Text.RegularExpressions.Regex.IsMatch(s2, sP));
      

  2.   

    cpp2017(幕白兄) ( ) 信誉:100    Blog  2006-11-15 17:12:47  得分: 0  
     
     
       原贴我的理解错误,不能全拿你的分 string s1 = "AAAA<%/*CCCCC*/%>BBBBB";
            string s2 = "tafasfasdfasdfasdf";
            string sP = "<\\%\\/\\*.*?(\\*\\/%>)";
            Response.Write(System.Text.RegularExpressions.Regex.IsMatch(s1, sP));
            Response.Write(System.Text.RegularExpressions.Regex.IsMatch(s2, sP));
      
     幕白兄:
    能搞个 匹配 s1为false,匹配s2为真的吗?先谢了.