3 ms·
I've been looking for such a beast in the wild for quite some time. I've seen a few on CPAN that'll take a regex (or some type of expression, or some limited di
by elblanco 16y ago
I've been looking for such a beast in the wild for quite some time. I've seen a few on CPAN that'll take a regex (or some type of expression, or some limited dialect of regex) and spit out a few random strings. Even Microsoft's REX tool (http://research.microsoft.com/en-us/projects/rex/ http://research.microsoft.com/en-us/projects/rex/), which is the best I've seen, gives nondeterministic random results.
Having a tool that would take a PCRE (or some subset of the language), apply some constraints on repetition operators (like *->{0,2}, +->{1,2}) etc., spit out a deterministic list of values (don't care how long so long as it's reasonably finite) would be extremely powerful for software testing. Even the rather limited capabilities in REX have helped me fix some invalid assumptions I was making about valid inputs.
It's always seemed strange to me that regular expressions are described in the literature as string generators, yet I've pretty much only ever seen them used as string acceptors in practice in the form of a predicate (s in set <REGEX>?).