Pattern pattern = Pattern.compile("1"); Matcher matcher = pattern.matcher("111"); while (matcher.find()) { System.out.println(matcher.group()); }