curious-odd-man / RgxGen

Regex: generate matching and non matching strings based on regex pattern.
Apache License 2.0
86 stars 14 forks source link

iterateUnique() does not consider "a?b|c" equivalent to "(a?b)|c" #61

Closed Kaljurand closed 3 years ago

Kaljurand commented 3 years ago

The optional "a" in the first pattern seems to confuse the generator to miss the "b". Adding brackets (2nd pattern) avoids the error.

import com.github.curiousoddman.rgxgen.RgxGen;

public class MyClass {

    public static void main(String args[]) {
        // "": WRONG
        System.out.println(new RgxGen("a?b|c").iterateUnique().next());
        // "b": OK
        System.out.println(new RgxGen("(a?b)|c").iterateUnique().next());
    }
}