Faisal Ansari wrote:il keep that in mind from the next time onwards....
can anyone help me with the answer to the above question
Well it goes like this
Pattern is = \d* --> That means zero or more occurrences of the integer
input is = ab34ef
so the pattern matches with all characters and the index of the occurence is returned with the method start() and group() will return the matching string. Because of * a,b, e and f are matched. At the 2nd index 34 will be matched and it will be printed, since it has *, it will also match the index beside the matched string which is 4 here, so 34 is the matching string and the 4 is the matching location for nothing, hence 4 printed twice.
So it is like - (0) a (1) b (2) 34 (3) wont be considered as the string is consumed, thats why 3 is not printed in the output (4) for nothing (5) e (6) f...all other indexes matching except 2nd index ( 34 ) are for the "*", means it matches the empty.