Generative regular expressions
Typically in our work we use regular expressions in capture or match operations. However, regular expressions can be used - manually at least - to generate legal sentences that match the regular expression. Of course, some regular expressions can match infinitely long sentences, e.g., the expression .+ . I have a problem that could be solved by using a regular expression sentence generating algorithm. In pseudocode, it would operate something like this: re = generate("foo(bar|baz)?", max_match = 100); #Don't give me more than 100 results assert re == ("foobar", "foobaz", "foo"); What algorithm