src/share/classes/java/util/regex/Pattern.java

Print this page

        

@@ -4332,11 +4332,10 @@
 
             if (info.deterministic && cmin == cmax)
                 info.deterministic = detm;
             else
                 info.deterministic = false;
-
             return next.study(info);
         }
     }
 
     /**

@@ -4413,10 +4412,12 @@
             }
             return ret;
         }
         // Aggressive group match
         boolean match0(Matcher matcher, int i, int j, CharSequence seq) {
+            // don't back off passing the starting "j"
+            int min = j;
             int[] groups = matcher.groups;
             int save0 = 0;
             int save1 = 0;
             if (capture) {
                 save0 = groups[groupIndex];

@@ -4450,11 +4451,11 @@
                         if (match0(matcher, i, j, seq))
                             return true;
                         break;
                     }
                 }
-                while (j > cmin) {
+                while (j > min) {
                     if (next.match(matcher, i, seq)) {
                         if (capture) {
                             groups[groupIndex+1] = i;
                             groups[groupIndex] = i - k;
                         }

@@ -4542,11 +4543,10 @@
             if (info.deterministic && cmin == cmax) {
                 info.deterministic = detm;
             } else {
                 info.deterministic = false;
             }
-
             return next.study(info);
         }
     }
 
     /**