Using java.util.regex (jdk 1.6), the regular expression 201210(\\d{5,5})Test applied to the subject string 20121000002Test only captures <
java.util.regex
201210(\\d{5,5})Test
20121000002Test
for (int i = 1; i <= m1.groupCount(); i++) { ↑ your problem