Pattern p = Pattern.compile("(\\d)([A-C])");
Matcher m = p.matcher("0A");
if (m.matches()) {
System.out.println(m.group(0));// 注意,group(0)总是返回整个匹配字串
System.out.println(m.group(1)); //0
System.out.println(m.group(2)); //A
}
Pattern p = Pattern.compile("(\\d)([A-C])");
Matcher m = p.matcher("0A");
if (m.matches()) {
System.out.println(m.group(0));// 注意,group(0)总是返回整个匹配字串
System.out.println(m.group(1)); //0
System.out.println(m.group(2)); //A
}