idea 和 andriod studio里面的输出结果不一样。

解决方案 »

  1.   

    你代码有问题
    public class RegexMatches
    {
        private static final String REGEX = "\\bcat\\b";
        private static final String INPUT =
                                        "cat cat cat cattie cat";
     
        public static void main( String args[] ){
           Pattern p = Pattern.compile(REGEX);
           Matcher m = p.matcher(INPUT); // 获取 matcher 对象
           int count = 0;
     
           while(m.find()) {
             count++;
             System.out.println("Match number "+count);
             System.out.println("start(): "+m.start());
             System.out.println("end(): "+m.end());
          }
       }
    }
      

  2.   

    可是在新版本java中,字符串可以直接调用matches()函数进行正则匹配,关键是同样的语句在IntelliJ IDEA和Android Studio中,一个被判定为true,一个被判定为false.
      

  3.   

    \\p{Punct}这个是什么意思??????