import java.util.regex.*;
public class Regex2 {
public static void main(String[] args) {
Pattern p = Pattern.compile("\\d*");
Matcher m = p.matcher("ab34ef");
boolean b = false;
while ( m.find()) {
System.out.print(m.start() + m.group());
}
}
}
Why this code produce output: 01234456