Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there any way to get all the possible outcomes of a regular expression pattern?

is there any way to get all the possible outcomes of a regular expression pattern?. everything I've seen refers to a pattern that is evaluated against a string. but what I need is to have a pattern like this:

^EM1650S(B{1,2}|L{1,2})?$

generate all possible matches:

EM1650S
EM1650SB
EM1650SBB
EM1650SL
EM1650SLL
like image 910
etasoft Avatar asked Jan 27 '12 19:01

etasoft


1 Answers

In the general case, no. In this case, you have almost no solution space.

There's a section covering this in Higher Order Perl (PDF) and a Perl module. I never re-implemented it in anything else, but I had a similar problem and this solution was adequate for similarly-limited needs.

like image 55
Dave Newton Avatar answered Oct 13 '22 00:10

Dave Newton