0

Is there a site or way to output all of the permutations of a regex pattern?

I made a simple pattern here with desired output from this 'app':

https://regex101.com/r/lE2tS8/2

or see below:

(?<TERM>(Big |Small )(Brown |Green |Red )(Ball|Box))
  • Big Brown Ball
  • Big Green Ball
  • Big Red Ball
  • Small Brown Ball
  • Small Green Ball
  • Small Red Ball
  • Big Brown Box
  • Big Green Box
  • Big Red Box
  • Small Brown Box
  • Small Green Box
  • Small Red Box
Mark H
  • 249
  • 2
  • 10
  • 6
    but it could be infinite.. – ergonaut Oct 05 '15 at 17:40
  • It can not be achieved with just regex. You'd need _some_ language to compute the logic. – hjpotter92 Oct 05 '15 at 17:43
  • Also, look at: http://stackoverflow.com/questions/15950113/generate-all-valid-values-for-a-regular-expression – Nir Alfasi Oct 05 '15 at 17:46
  • @ergonaut: infinite only if you have non finite quantifiers: `*`, `+`, `{a,}` or recursions, but that isn't the case in this example. – Casimir et Hippolyte Oct 05 '15 at 18:04
  • Since a regex is really a mini program, this is a [halting problem](https://en.wikipedia.org/wiki/Halting_problem) and as such is only open to being modeled for general regex's. This specific regex is more amenable to analysis. Have you tried something like [this?](http://hackingoff.com/compilers/regular-expression-to-nfa-dfa) – dawg Oct 05 '15 at 19:01

0 Answers0