RgxGen icon indicating copy to clipboard operation
RgxGen copied to clipboard

generate returns String which does not match the Regex

Open hofi1 opened this issue 1 year ago • 1 comments

Describe the bug The generate function returns strings, which do not match the given RegEx

To Reproduce

  1. With regex pattern '(?=(abc.*))(?=([a-z0-5]*))'
  2. 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);
}
  1. See error Generates String "abc(dfCxVLcJ P1&y~pw|Te6b<Z^&jNUyG!H8nin<bug_\\wV4]Z1*b+H3<Fkmcrbgx225ur2uekvxenraybvjpmdv3ot15fh53l4kmmq53iyens5rzkatqon"

Expected behavior Generate a string which matches the regex

Screenshots Screenshot

Environment:

  • OS: OSX 14.4.1 (23E224)
  • JDK/JRE version Amazon Corretto 21.0.2
  • RgxGen Version Maven Central 2.0

hofi1 avatar May 17 '24 22:05 hofi1

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

curious-odd-man avatar May 18 '24 07:05 curious-odd-man