1

How can I create such program in Java that could accept automata regular expression and a minimum string length (int) and generate possible Strings?

examples of regular regular expressions are

regex             possible strings
(a+b)*            abbababababbbab
ab(a+b)           ababababab, abaaaa, abbbbb, abbaba, . . .
aioobe
  • 413,195
  • 112
  • 811
  • 826
John
  • 55
  • 1
  • 4

2 Answers2

2
  1. Compile an automaton (standard automata text book exercise)
  2. Simulate the automaton by walking along the edges recording which symbols you use (branching into parallel simulations if needed)
  3. Output the current string each time you reach an accepting state.
aioobe
  • 413,195
  • 112
  • 811
  • 826
0

This library mentioned in this post (which generates a random, matching string, I believe) maybe of use

Using Regex to generate Strings rather than match them

Community
  • 1
  • 1
matt freake
  • 4,877
  • 4
  • 27
  • 56