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

JAVA学习网 2017-08-08 11:32:02

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

}

阅读(811) 评论(0)