正则验证:Pattern,Matcher

时间:2023-03-10 05:09:01
正则验证:Pattern,Matcher
     public static void main(String[] args) {
String regex="([a-z]{1})(\\d{2})";
String candidate = "sdsdx99sdsdc99Supr99erJau99va";
Pattern p=Pattern.compile(regex);
Matcher matcher=p.matcher(candidate);
while(matcher.find()){
int n=matcher.groupCount();
// for(int i=0;i<=n;i++){
// String str=matcher.group(i);
// System.out.println(str);
// } System.out.println(n);
}
// matcher.reset();
// System.out.println(matcher.group());
//
//
// System.out.println(matcher.replaceAll("xulu")); }