title: System.out.print removes Matcher class exception
body: <p>So I was using Jsoup to crawl some web pages and this wired issue happens.</p>
  
  <p>With the regex expression of</p>
  
  <pre><code>// Sets the prefix for all pages to prevent navigate to unwanted pages.
  String prefix = "https://handbook.unimelb.edu.au/%d/subjects";
  // Postfix for search page
  String searchPostfix = "(\\?page=\\d+)?$";
  // Postfix for subject page
  String subjectPostfix = "\\/(\\w+)(\\/.+)?$";
  
  String root = String.format(prefix, "2019");
  String pattern = root.replace("/", "\\/").replace(".", "\\.");
  Pattern reg1 = Pattern.compile("^" + pattern + searchPostfix);
  Pattern reg2 = Pattern.compile("^" + pattern + subjectPostfix);
  </code></pre>
  
  <p>With these regex patterns. I ran it with string</p>
  
  <pre><code>String s1 = "https://handbook.unimelb.edu.au/2019/subjects/undergraduate";
  </code></pre>
  
  <p>And with a method:</p>
  
  <pre><code>private String getSubjectCode(String link) {
      System.out.println(link);
      if (isSubjectPage(link)) {
          Matcher subjectMatcher = subjectPattern.matcher(link);
          System.out.println(link);
          // System.out.println(subjectMatcher.matches());   ## Exception if commented
          System.out.println(subjectMatcher.group(0));
          System.out.println(subjectMatcher.group(1));
  
  
          return subjectMatcher.group(1);
      }
      return null;
  }
  </code></pre>
  
  <p>What will happen is, if I left that commented line uncommented, the program ran well.</p>
  
  <p>However, if I comment that line</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalStateException: No match found
      at java.base/java.util.regex.Matcher.group(Matcher.java:645)
      at Page.Pages.getSubjectCode(Pages.java:54)
      at Page.Pages.enqueue(Pages.java:85)
      at Crawler.Crawler.parsePage(Crawler.java:41)
      at Crawler.Crawler.crawl(Crawler.java:51)
      at Main.main(Main.java:9)
  </code></pre>
  
  <p>The above Exception will be raised, why will a print line affect how the program is running?</p>
  
  <p>Also, without comment</p>
  
  <pre><code>System.out.println(subjectMatcher.matches());   // Exception if commented
  // out -&gt; true
  </code></pre>