RgxGen
RgxGen copied to clipboard
NPE on specific regex
Describe the bug
I get a NPE with the following regex ^[^\p{C}\p{Z}\s]*[^\p{C}]+[^\p{C}\p{Z}]*$ which didn't happen on version 1.4.
To Reproduce Steps to reproduce the behavior:
- regex:
^[^\p{C}\p{Z}\s]*[^\p{C}]+[^\p{C}\p{Z}]*$ RgxGen.parse("^[^\\p{C}\\p{Z}\\s]*[^\\p{C}]+[^\\p{C}\\p{Z}]*$").generate()- See error below
at com.github.curiousoddman.rgxgen.nodes.SymbolSet.ofUnicodeCharacterClass(SymbolSet.java:72)
at com.github.curiousoddman.rgxgen.parsing.dflt.DefaultTreeBuilder.createUnicodeSymbolSetNode(DefaultTreeBuilder.java:463)
at com.github.curiousoddman.rgxgen.parsing.dflt.DefaultTreeBuilder.handleEscapedCharacter(DefaultTreeBuilder.java:410)
at com.github.curiousoddman.rgxgen.parsing.dflt.DefaultTreeBuilder.handleBackslashInsideSquareBrackets(DefaultTreeBuilder.java:671)
at com.github.curiousoddman.rgxgen.parsing.dflt.DefaultTreeBuilder.handleSquareBrackets(DefaultTreeBuilder.java:631)
at com.github.curiousoddman.rgxgen.parsing.dflt.DefaultTreeBuilder.parseGroup(DefaultTreeBuilder.java:228)
at com.github.curiousoddman.rgxgen.parsing.dflt.DefaultTreeBuilder.build(DefaultTreeBuilder.java:732)
at com.github.curiousoddman.rgxgen.parsing.dflt.DefaultTreeBuilder.get(DefaultTreeBuilder.java:741)
at com.github.curiousoddman.rgxgen.RgxGen.<init>(RgxGen.java:65)
at com.github.curiousoddman.rgxgen.RgxGen.parse(RgxGen.java:59)
at com.github.curiousoddman.rgxgen.RgxGen.parse(RgxGen.java:48)
Expected behavior Property generate a value.
Environment (please complete the following information):
- MacOS
- JDK 21
- RgxGen Version 2.0
Additional context It works with RgxGen 1.4.
I will look into that. Though I am curious which results did you get in 1.4, because character classes were not supported in 1.4 at all. So the results could not have been correct anyway.
Ok. I see that this category (\p{C}) is not yet supported :
https://github.com/curious-odd-man/RgxGen/blob/4e2085bd66ea80cabc0883127560facba15908f9/src/main/java/com/github/curiousoddman/rgxgen/model/UnicodeCategory.java#L193
I will try to add it.
With 1.4 I get something like the below which passes the matches test:
System.out.println("%u@O2L1K\"jn:;3e&(e<QN5q4HeN'A:(\\c^F.03-vyvKW5zW/u~h,(aSyGHPKIA);XNY#v@[hEh(Og=NEVq;0+VN#sv\\wOVE<t[RNo(Tg'nFk)\\GZ]o%|~d3KNi?J\"l2bGO#7E*BQo 8qS25\\A<8yLO<JmmP)ABDr^#kZ[$8B^R=hFMBec,;IdXF!Q[vVe|O_5]1#-$d(N#+2Vh'HbB[#M8]T6,P6VJ3sT|NGOe=5k'OO*Asrds%*@XAy".matches("^[^\\p{C}\\p{Z}\\s]*[^\\p{C}]+[^\\p{C}\\p{Z}]*$"));