测试正则表达式的分组
import java.util.regex.*;
public class RegGroup{
public static void main(String[] args){
Pattern p = Pattern.compile("([a-z]{2,4})(\\d+)");
Matcher m = p.matcher("sdf1234-fasd345-fd46");
while(m.find()){
System.out.println(m.group());
//System.out.println(m.group(1));
//System.out.println(m.group(2));
}
}
}
浙公网安备 33010602011771号