java正则表达式(基本语法)

Public class cla001{
public int countCode(String a){
//表达式(找出"conxe"中的字符,其中'x'为任意字符)
     String b= "co(.)e";
     //表达式写入匹配器
    Pattern p = Pattern.compile(b);
    //匹配
     Matcher m = p.matcher(a);
/**
*使用
*//
     int num = 0;
//while循环找到就加1
      while(m.find()){
      num++;
   }
 //返回结果
   return num;
  }
}

}

posted on 2017-08-07 17:26  java羊羔  阅读(226)  评论(0编辑  收藏  举报

导航