title: How do I use a regex to find a consecutive repeat in a string (i.e. [12][12]) but only of length 2 or greater?
body: <pre><code>import java.util.regex.Matcher;
  import java.util.regex.Pattern;
  
  public class test {
      public static void main(String[] args) {
          String a ="12341234";
          String regex="^(\\d+?)\\1$";
          Pattern p=Pattern.compile(regex);
          Matcher matcher = p.matcher(a);
  
          while(matcher.find()) {
              System.out.println(matcher.group(1));
          }
      }
  }
  </code></pre>
  
  <p>By using the Matcher and the regex above, I get any repeat. However, I only want repeats of size 2 or greater. When I tried doing the regex of </p>
  
  <pre><code>^(\\d+?){2,100}\\1$
  </code></pre>
  
  <p>, nothing was returned when I executed the program even though there was a repeat between length 2 and 100. What am I doing wrong?</p>