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
m1.groupCount() returns the number of capturing groups, ie. 1 in your first case so you won't enter in this loop for(int i = 1; i
m1.groupCount()
for(int i = 1; i
It should be for(int i = 1; i<=m1.groupCount(); i++)
for(int i = 1; i<=m1.groupCount(); i++)