Skip to content

Slow generation of some RegExps #43

@TheJavaGuy

Description

@TheJavaGuy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions