title: how to track catastrophic backtracking in your regular expressions?
body: <p>I am using Apache regexp as library to validate regex. I want to know how to track if some regex is causing catastrophic backtracking.
  What I want to know is, is there some trick to catch which regex and the string value that causing catastrophic backtracking?
  I tried a little modify in class RE.java, but not as expected. </p>
  
  <p><strong>This my modification:</strong></p>
  
  <pre><code>    public RE(String pattern) throws RESyntaxException
  {
      this(pattern, MATCH_NORMAL);
      paramString = pattern;
  }
  
  
  public RE(String pattern, int matchFlags) throws RESyntaxException
  {
      this(new RECompiler().compile(pattern), matchFlags);
      paramString = pattern;
  }
  
  
  int callcounterMN = 0;
  protected int matchNodes(int firstNode, int lastNode, int idxStart)
  {
      callcounterMN++;
      if (callcounterMN == 100) {
          try {
              String pc1 = new Exception().getStackTrace()[5].getClassName();
              if (pc1.indexOf("UpdateWebForm") &gt; 1)     
                  System.out.println("regex loop reach "+callcounterMN+"  with regex : "+paramString+" "+this.search.substring(0));
          } catch (Exception e) {}
      }
  </code></pre>