Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal Capacity Argument Exception Raised #90

Open
rmabb123 opened this issue Dec 6, 2023 · 4 comments
Open

Illegal Capacity Argument Exception Raised #90

rmabb123 opened this issue Dec 6, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@rmabb123
Copy link

rmabb123 commented Dec 6, 2023

Stacktrace generated with the following regex:

String pp = "[\\i-[:]][\\c-[:]]*";
RgxGen rgxGen = new RgxGen(pp);

Generates:
java.lang.IllegalArgumentException: Illegal Capacity: -13

Using the online regex testing https://regex101.com
The following is valid: \\:\\:c:

RgxGen Version :1.4
OpenJDK 17

@rmabb123 rmabb123 added the bug Something isn't working label Dec 6, 2023
@FWDekker
Copy link

FWDekker commented Dec 6, 2023

Do you mean String pp = "[\\i-[:]][\\c-[:]]*"; or String pp = "[\\\\i-[:]][\\\\c-[:]]*";?


I don't think your regex is valid.

If I ask regex101 about [\i-[:]][\c-[:]]*, I get two errors:

  1. \i This token has no special meaning and has thus been rendered erroneous
  2. - Character range is out of order

And if I ask regex101 about [\\i-[:]][\\c-[:]]*, I also get two errors:

  1. - Character range is out of order
  2. - Character range is out of order

The "Illegal capacity" error in RgxGen also means "Character range is out of order". For example, asking RgxGen to generate [z-a] gives "Illegal Capacity: -24".

@rmabb123
Copy link
Author

rmabb123 commented Dec 7, 2023

When testing with regex101 using [\\i-[:]][\\c-[:]]*, you need to ensure you have selected "Java 8" as the flavor.
If you try testing with any of the other flavors, then you do indeed get an error.

@FWDekker
Copy link

FWDekker commented Dec 7, 2023

Ah I see. RgxGen's supported syntax is not complete, but for what it's worth I think you can use [\\i\-:][\\c\-:]* instead.

@rmabb123
Copy link
Author

rmabb123 commented Dec 7, 2023

I see two issues:

  • The "-" is being treated as a range when it should be just another char (the original issue) because it comes are the end of a group (the next char is an unescape "[" which is the start or a new inner grouping)
  • If you remove the hyphen, then it still fails because it does not recognise the "[:]" as being another char

Yes, your version does work but as you say "the supported syntax is not complete"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants