title: Regex execution is too slow in java
body: <p>My purpose is to match this kind of different urls:<br/>
     url.com<br/>
     my.url.com<br/>
     my.extended.url.com<br/>
     a.super.extended.url.com<br/>
     and so on...<br/></p>
  
  <p>So, I decided to build the regex to have a letter or a number at start and end of the url, and to have a infinite number of "subdomains" with alphanumeric characters and a dot. For example, in "my.extended.url.com", "m" from "my" is the first class of the regex, "m" from "com" is the last class of the regex, and "y.", "extended." and "url." are the second class of the regex.</p>
  
  <p>Using the pattern and subject in the code below, I want the find method to return me a false because this url must not match, but it uses 100% of CPU and seems to stay in an infinite loop.</p>
  
  <pre>
    <code>  
      String subject = "www.association-belgo-palestinienne-be";
      Pattern pattern = Pattern.compile("^[A-Za-z0-9]\\.?([A-Za-z0-9_-]+\\.?)*[A-Za-z0-9]\\.[A-Za-z]{2,6}");
  
      Matcher m = pattern.matcher(subject);
      System.out.println("    Start");
      boolean hasFind = m.find();
      System.out.println("    Finish : " + hasFind);
    </code>
  </pre>
  
  <p>Which only prints:</p>
  
  <pre>
    <code>
        Start
    </code>
  </pre>
  
  <p>I can't reproduce the problem using regex testers.<br/>
    Is it normal ? Is the problem coming from my regex ?<br/>
    Could it be due to my Java version (1.6.0_22-b04 / JVM 64 bit 17.1-b03) ?<br/></p>
  
  <p>Thanks in advance for helping.</p>