Generex icon indicating copy to clipboard operation
Generex copied to clipboard

Slow generation of some RegExps

Open TheJavaGuy opened this issue 7 years ago • 0 comments

Hello @mifmif ,

I noticed one issue when generating some RegExps. If we try this:

Generex generex = new Generex("(.{1,6})( *, *(.{1,6})){0,5}");
System.out.println(generex.random());

it takes about 1 second to finish. But, if we try this RegEx:

Generex generex = new Generex("(.{1,6})( *, *(.{1,6})){0,12}");
System.out.println(generex.random());

it takes about 40 seconds.

Finally, the code

Generex generex = new Generex("(.{1,6})( *, *(.{1,6})){0,15}");
System.out.println(generex.random());

took a whopping 3 minutes and generated one character as a result.

Now I'm perfectly aware that users can write all sorts of RegExps. It's probably impossible to make code which efficiently generates them all. Yet I hope there's a possibility that for some cases generation might be faster.

TheJavaGuy avatar Feb 07 '18 15:02 TheJavaGuy