progs/catastrophic.java
changeset 558 447ed6c7cdad
parent 474 4bdf0dedd708
child 616 24bbe4e4b37b
equal deleted inserted replaced
557:9ab8a6fc58c0 558:447ed6c7cdad
     1 // a case of catastrophic backtracking in Java
     1 // A case of catastrophic backtracking in Java 8
       
     2 //-----------------------------------------------
     2 //
     3 //
     3 // regexp: (a*)*b
     4 // regexp: (a*)*b
     4 // strings: aa....
     5 // strings: aa....
       
     6 //
       
     7 // compile:    javac catastrophic.java
       
     8 // call with:  java catastrophic
       
     9 //
       
    10 // IMPORTANT: 
       
    11 // Java 9 improved its regex matching engine.
       
    12 // This example is now much faster.
       
    13 //
     5 
    14 
     6 import java.util.regex.*;
    15 import java.util.regex.*;
     7 
    16 
     8 public class catastrophic {
    17 public class catastrophic {
     9     public static void main(String[] args) {
    18     public static void main(String[] args) {