Non Capturing Groups
Groups beginning with (?: are either pure, non-capturing groups that do not capture text and do not count towards the group total, or named capturing group.
Program
import java.util.regex.Pattern; import java.util.regex.Matcher; public class Javaapp { public static void main(String[] args) { Pattern pat = Pattern.compile("([0-9]{2})(?:[0-9]{2})([0-9]{4})"); Matcher mat = pat.matcher("1022199009282010"); while(mat.find()) { System.out.println(mat.group(1)+"/"+mat.group(2)); } } }