RgxGen
RgxGen copied to clipboard
generate returns String which does not match the Regex
Describe the bug The generate function returns strings, which do not match the given RegEx
To Reproduce
- With regex pattern '(?=(abc.*))(?=([a-z0-5]*))'
- Use code/API
RgxGen rgxGen = RgxGen.parse(regex);
Random rnd = new Random(1234);
for (int counter = 0; counter < 100000; counter++) {
String generatedString = rgxGen.generate(rnd);
System.out.println(generatedString);
assertTrue(matchesParser.parse(generatedString), "String: \'" + generatedString + "\' SHOULD match the regex: " + regex);
}
- See error
Generates String "abc(dfCxVLcJ P1&y~pw|Te
6b<Z^&jNUyG!H8nin<bug_\\wV4]Z1*b+H3<Fkmcrbgx225ur2uekvxenraybvjpmdv3ot15fh53l4kmmq53iyens5rzkatqon"
Expected behavior Generate a string which matches the regex
Screenshots
Environment:
- OS: OSX 14.4.1 (23E224)
- JDK/JRE version Amazon Corretto 21.0.2
- RgxGen Version Maven Central 2.0
Hello! Thanks for reporting this.
Please note that this is a known issue - lookaround patterns do not function properly due to design limitations. This is also mentioned in Readme - section Limitations.
Best Regards, Vlad